Quote:
Originally Posted by rungss
I think this should work
<?php
$connection=mysql_connect("localhost","USERNAME"," PASSWORD");
$db=mysql_select_db("DATABASENAME",$connection);
$result = mysql_query("select password from passwordtable where username=$_POST['username']");
if(!$result)
{
echo "oops! The Username you entered does not exist";
}
else
if($_POST['password']!= mysql_result($result, 0))
{
echo "You entered an incorrect password";
}
else if($_POST['newpassword']!=$_POST['confirmnewpasssword'])
{
echo "The new password and confirm new password fields must be the same";
}
else
$sql=mysql_query(UPDATE passwordtable SET password=$_POST['newpassword'] where username=$_POST['username']);
if($sql)
{
echo "Congratulations You have successfully changed your password";
}
?>
|
Dude yor Script was ok but there are some systax error.
1. $result = mysql_query( "select password from auth_users where username= '$_POST[username]'");
2. $sql=mysql_query( "UPDATE auth_users SET password= '$_POST[newpassword]' where username= '$_POST[username]'");
thats it.... Then this code will work..100% working 
|