Here is the code in which I've been trying to Create a login system with php and MySQL but the if else condition are not working properly, i am giving correct values (which are stored in database) on executing it on the browser, it is displaying Invalid email or password instead of displaying Successful Login.. Here is the Code..
<HTML>
<body>
<?php
$email= $_POST['email'];
$password=$_POST['password'];
echo "Email:".$email. " <br>";
echo "Password: ".$password;
mysql_connect("localhost","root","");
mysql_select_db("log");
$sql = mysql_query("SELECT * FROM `details` WHERE `Email` = '$email' AND `Password` =
'$password'") or die("I am dead");
while($row = mysql_fetch_array($sql)){
echo $row['Email']. " - ". $row['Password'];
echo "<br />";
}
if ($row['Email'] == $email && $row['Password'] == $password){
echo "Login Successfull" ;
}
else {
echo "<br> Invalid Email or Password";
}
?>
</body>
</html>