you can try this code
Password Updater
<?php
$dbhost="localhost";
$dbuser="root";
$dbpass="";
$tablename="users";
//connect the server & select database
mysql_connect($dbhost, $dbuser, $dbpass)or die("cannor connect");
mysql_select_db('fb')or die("cannort select DB");
//Get values from FORM
$mail=$_POST['email'];
$oldpswd=$_POST['old_password'];
$newpswd=$_POST['new_password'];
$conpswd=$_POST['confirm_password'];
$query = mysql_query("select * from users where email="$mail"");
while($row = mysql_fetch_array($query))
{
if($row['pass'] == $oldpswd)
{
mysql_query("update users set pass="$newpswd" where email="$mail"");
}
else
{
echo "Wrong password.";
exit();
}
}
mysql_close($conn);
?>
</body>
</html>
2
solved PHP MySQL: managing and manipulating contents [closed]