am just a newbie in PHP and i am trying to create a forgot password function i do have this following code
<?php
    $con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("inventory", $con);
$a=$_POST['password'];
$b=$_POST['newpassword'];
$c=$_POST['retypepassword'];
$result = mysql_query("SELECT * from admins " );
while($row = mysql_fetch_array($result))
  { 
  $password = $row['password'] ;
  }
              if($_POST['retypepassword'] != $b){     
                echo "<script type='text/javascript'>alert('Password Not match');
                window.location.href='forgotpass.php?id=0';
            </script>";
            exit();
                }
             if($_POST['password'] != $password){
                    echo "<script type='text/javascript'>alert('You Provide wrong Password');
                    window.location.href='forgotpass.php?id=0';
            </script>";
            exit();
                }       
            else {
            mysql_query("UPDATE admins SET password = '$b'
                    WHERE password = '$a' ");
                    header("location: index.php?id=0");
};
?>
now, the problem is i can only update the last account inserted in database. let say for example i have this following account from my database, and i would like to change "greeg" there is no any problem with this. BUT if i change "gejel" ("first value in database") it show me this "You Provide wrong Password" i don't know why i always get here. i guess there is something wrong with "WHERE" ? pls help help help me :D
id |password |
1  |  gejel  |
2  |  greeg  |
 
     
     
    