Home > Blockchain >  page redirects when clicking form
page redirects when clicking form

Time:12-30

I am having an issue where when I click on the form I made to enter data into the input boxes, the page is redirecting to ./about

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="styles.css">
    <title></title>
  </head>
  <body>

    <header>
      <h1><span>AJAX CORP</span></h1>
    </header>
    <nav>
      <ul>
        <li><a href="/">home</a></li>
        <li><a href="/create-user">register</li>
        <li><a href="/about">about</li>
      </ul>
    </nav>
    <div >
        <h1>User Creation Form</h1>
        <form action="http://127.0.0.1:3000/create-user/result" method="post" id="user-create-form">
          <input type="email" name="email" id="user-create-email" placeholder="E-mail" required><br>
          <input type="text" name="username" id="user-create-username" placeholder="Username" required><br>
          <input type="password" name="password" id="user-create-password" placeholder="Password" required><br>
          <input type="submit" name="submit" id="user-create-submit" value="Submit">
        </form>
    </div>
  </body>
</html>

I have narrowed it down to being an HTML issue (I think) as when I move the nav below the form the issue does not persist. I am using ejs and express. If I change the href in the about anchor to another path, it redirects me to that path.

CodePudding user response:

You didn't close the anchor tags

CodePudding user response:

It is because you didn't close the tags properly. Try the below code

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="styles.css">
    <title></title>
  </head>
  <body>

    <header>
      <h1><span>AJAX CORP</span></h1>
    </header>
    <nav>
      <ul>
        <li><a href="/">home</a></li>
        <li><a href="/create-user">register</a></li>
        <li><a href="/about">about</a></li>
      </ul>
    </nav>
    <div >
        <h1>User Creation Form</h1>
        <form action="http://127.0.0.1:3000/create-user/result" method="post" id="user-create-form">
          <input type="email" name="email" id="user-create-email" placeholder="E-mail" required><br>
          <input type="text" name="username" id="user-create-username" placeholder="Username" required><br>
          <input type="password" name="password" id="user-create-password" placeholder="Password" required><br>
          <input type="submit" name="submit" id="user-create-submit" value="Submit">
        </form>
    </div>
  </body>
</html>

  • Related