code not updating properly
Posted: Fri Nov 18, 2011 2:41 am
Hi,
I tried changing the password and it is not working. It will display that the password got changed successfully but it will not change it in database. Is there any mistake in below code?
I tried changing the password and it is not working. It will display that the password got changed successfully but it will not change it in database. Is there any mistake in below code?
Code: Select all
<?php
$password=mysql_real_escape_string($_POST['newpassword']);
$password2=mysql_real_escape_string($_POST['confirmnewpassword']);
if ( strlen($password) < 5 or strlen($password) > 12 ){
echo "Password must be more than 5 char legth and maximum 12 char lenght<BR>";
}
if ( $password <> $password2 ){
echo "Both passwords are not matching";
}
if($password == $password2){
if(mysql_query("update users set password='$password' where empid='{$_SESSION['login']}'")){
echo "<font face='Verdana' size='2' ><center>Thanks <br> Your password changed successfully. Please keep changing your password every 2 months for better security</center></font>";
}
else{
echo mysql_error();
}
}