Showing Wrong Password Or Username Even Though It Is Correct Password Or Username
I'm creating login form using AJAX, i,m trying to make it work from 4 days but unable to do so in this i have few issues i.e., if i enter Valid username & password also then a
Solution 1:
remove AND password='$hashed_password'
from
$sql = "SELECT * FROM users WHERE username = '$myusername' AND password='$hashed_password'";
just check whether the username exists
using
$sql = "SELECT * FROM users WHERE username = '$myusername'";
and then check the password using password_verify()
change your
password_verify(){
echo'success';
}else{
echo'error';
}
and in ajax
success:function(data){
if(data.trim() == 'success'){
window.location.href='success.php'
}elseif(data.trim()== 'error'){
///use some javascript to display the error message
}
}
Solution 2:
In your submit function on your login.php you have set the your variables wrong. Change them to this:
var username = $("#username").val();
var password = $("#password").val();
After you do that, do what v Sugumar suggested in his answer.
Solution 3:
You have defined password twice instead of Username.
var password = $("#username").val();
var password = $("#password").val();
Correct this and check your code again.
Post a Comment for "Showing Wrong Password Or Username Even Though It Is Correct Password Or Username"