I have a form to change the password of user. It takes the input on profile page and then sends to another page for processing. But i am getting the error login_failed even if i am leaving any of the field blnk. In blank case, the error should be Fill all the fields. Can someone tell where is the problem.
<form method="post" action="updatepassword.php">
<input name="pass" type="text" placeholder="Old password" />
<input name="pass1" type="text" placeholder="New password" />
<input name="pass2" type="text" placeholder="Confirm password" />
<input id="butt" type="submit" value="Update" name="pinchange">
</form>
updatepassword.php
<?php
include_once("login_status.php");
}
if(isset($_POST['pinchange']))
{
$pass=md5($_POST['pass']);
$pass1=md5($_POST['pass1']);
$pass2=md5($_POST['pass2']);
if($pass==""||$pass1==""||$pass2==""){ echo "Fill all the fields"; exit();}
else{
$sql = "SELECT id,password FROM users WHERE username='$log_username' ;
$query = mysqli_query($db_conx, $sql);
$row = mysqli_fetch_row($query);
$db_id = $row[0];
$db_pass_str = $row[1];
if($pass != $db_pass_str){
echo "login_failed";
exit();
}
}
}
?>