1

I'm making this form that, for now, redirects, a user to another page after submitting a form. However, after the user is redirected, the form fields pop up in the url. I'm a beginner and I was wondering on how I can keep the url path to just what I specified in the "action" attribute of the form. Here's my code

<div>
     <form action="/test">
          <input type="text" name="login-username" id="login-username" placeholder="Username" />
          <input type="password" name="login-password" id="login-password" placeholder="Password" />
          <input type="submit" name="login-submit-button" id="login-submit-button" />
     </form>
</div>

After clicking the button, the url looks like this:

http://localhost:3000/test?login-username=&login-password=&login-submit-button=Submit

How can I keep it to just

http://localhost:3000/test

Marco Bonelli
  • 63,369
  • 21
  • 118
  • 128

1 Answers1

0

As mentioned clearly in this answer, default method of form on submit is GET with encoding of type x-www-form-urlencoded, which basically appends input data to the current URL.

Using method POST appends form-data inside the body of the HTTP request (data is not shown in URL).

Abhinav
  • 125
  • 6