I'm just new in PHP, I have the project which I'm still constructing and now Am working on Administrator area.
For now I'm writing the script which Update the password in the table by looking two criteria "username and fname" if the same with the entered one the password should change, And It does so successfully, but the problem is once I enter incorrect username it still update the password and doesn't show the message "The username you entered does not exist" as well as when I write wrong fname it doesn't show the message to, It real make me stacking where Am wrong, although I know there some where A'm wrong.
I request for any help to any one I'w be thankfully.
This my script
<?php
session_start();
//include mysqli_connect
$name = $_POST['fname'];
$newp = $_POST['newpword'];
$user=$_POST['username'];
$result = mysql_query("SELECT password FROM admin WHERE fname='$name'
AND username='$user' ");
if(!$result)
{
echo "The username you entered does not exist";
}
elseif(mysql_num_rows($result)>0)
$result=mysql_query("UPDATE admin SET password='$newp' where fname='$name'");
{
echo "Password change successfully";
echo"<br>";
echo"<a href=index.php> Click here to signin </a>";
exit;
}
{
echo "The new password and confirm new password fields must be the same";
}
?>