Checking if Username and Password is match or available - Jquery

前端 未结 1 386
悲哀的现实
悲哀的现实 2021-01-28 05:35

I\'m having a problem on my code which the username and password does not match. Here is my output. When the username and password is not match, then it will give a message that

相关标签:
1条回答
  • 2021-01-28 06:20

    Notes

    • You are wide open to SQL injection. You should be using prepared statements instead. Please read How can I prevent SQL injection in PHP?
    • You should not store passwords in plain text. Instead, use PHP's password_hash and password_verify functions to hash and verify.

    Answer

    You are using isset incorrectly. To check that multiple values are set, separate them by commas, not with &&:

    if(isset($_POST["user_name"], $_POST["password"]))
    

    Your PHP code as it currently stands won't produce any output as it will terminate with a fatal error on that line.

    In your jQuery, you're not specifying multiple selectors correctly. They should all be inside the same set of quotes:

    $('#username, #password').blur(function(){
    

    You also need to change this code, which will set both username and password values to the same thing:

    var username = $(this).val();
    var password = $(this).val();
    

    to

    var username = $('#username').val();
    var password = $('#password').val();
    
    0 讨论(0)
提交回复
热议问题