0

Imagine a simple PHP page with a password input field. The entered password goes into a $_POST variable and will be checked against a hash value on the server side. Very rudimentary.

Now what I need is that depending of whether the entered password is correct or incorrect a JavaScript (like this) should be executed first. Only after should the server do whatever it's supposed to do. For security reasons I don't want the hash value to be publish in the JavaScript.

How do you do that?

  • JS is client-side. Any values that your JS is able to see, the user will be able to see as well. – some coder guy Nov 12 '21 at 20:23
  • I know. That's why I'm asking. ;) – Three Year Old Nov 12 '21 at 20:32
  • 3
    No, you can't validate the password against a hash in Javascript without having the hash in Javascript. You must send the password to PHP and validate it there. Why not just send the password to PHP using Ajax and return success or fail and trigger what ever script you need to trigger? For the user, it will be the same experience. – M. Eriksson Nov 12 '21 at 21:49
  • Yes, I'm aware of that. So AJAX is the answer to my question? Thank you! :) – Three Year Old Nov 13 '21 at 12:07

0 Answers0