0

I'm using standard html form for login. like this

<form submit.delegate="login()"> 
     <input name="email" type="text">
     <input class="form-control" name="password" type="password"> 
     <button type="submit>SUBMIT</button>
</form>

The problem I'm facing is that sometimes the submit.delegate messes up and redirects me to url where all params are in plaintext like this http://localhost:9001/?email=myemail%40gmail.com&password=12345. How can I stop that? I could switch form to div instead beacuse I'm really only using it so enter key would automatically submit it? Should I do that or is there some better way to tell form to do nothing after login() method call? Keep in mind creating object and posting it is done programmatically so form doesn't have anything to do with that.

3
  • 1
    Because you are not defining any method attribute with form element, it is assigned as GET by default and in case of GET all of your form data will get showed in url. Use method=post in form element <form method=post> Commented May 4, 2017 at 11:51
  • Take a look at POST requests, or better yet oAuth. Commented May 4, 2017 at 11:51
  • When I use method="post" then form redirects me to blank page with error Cannot POST / Commented May 4, 2017 at 12:00

1 Answer 1

1

You use GET, so all the datas will be visible through URL. You should use POST to hide them.

use the attribute method="POST" on your <form> tag. So: <form submit.delegate="login()" method="POST">

To use the field's values on the target page, you will have to change $_GET['input_name'] with $_POST['input_name']

Have a look : https://www.w3schools.com/tags/ref_httpmethods.asp

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.