I'm new using php and I'm making a login window for my page where I want to compare if the email and password from the inputs are the same to those in the database; I already have the comparison for the email but I don't know how to retrieve the exact password for that email and compare it with the password input to know if it's the same. This is what I have for my php:
$password=$_POST['password'];
$email=$_POST['email'];
$query = mysql_query( "SELECT email FROM Register WHERE email = '$email'");
$query2 = mysql_query( "SELECT password FROM Register WHERE email = '$email', password = '$password'");
if(!$email)
{
if (!$password)
{
echo '
<script>
alert("Email and password are required.");
window.history.go(-1);
</script>';
exit;
}
else
{
echo '
<script>
alert("Email Required.");
window.history.go(-1);
</script>';
exit;
}
}
if (!$password)
{
echo '
<script>
alert("Password required.");
window.history.go(-1);
</script>';
exit;
}
else
{
if(!mysql_num_rows($query))
{
echo '
<script>
alert("The email is not the same or does not exist");
window.history.go(-1);
</script>';
exit;
}
if($query2==$password)
{
echo '
<script>
alert("Succesful Login");
window.history.go(-1);
</script>';
exit;
}
else
{
echo '
<script>
alert("Password is not the same, please verify.");
window.history.go(-1);
</script>';
exit;
}
}
By the way, thank you for your help