Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

<?

php
$dbhost = "localhost";
$dbname = "simpenan";
$dbuser = "user";
$dbpass = "pass";
//Connect to database
$link= mysql_connect ("$dbhost","$dbuser","$dbpass")or die("Could not
connect: ".mysql_error());
mysql_select_db("$dbname") or die(mysql_error());
$username = $_POST['username'];
$password = $_POST['password'];
$newpassword = $_POST['newpassword'];
$confirmnewpassword = $_POST['confirmnewpassword'];
$result = mysql_query("SELECT password FROM users WHERE
user_name='$username'");
if(!$result)
{
echo "The username you entered does not exist";
}
else if($password!= mysql_result($result, 0))
{
echo "You entered an incorrect password";
}
if($newpassword=$confirmnewpassword)
$sql=mysql_query("UPDATE users SET password='$newpassword' where
username='$username'");
if($sql)
{
echo "Congratulations You have successfully changed your password";
}
else
{

echo "The new password and confirm new password fields must be the
same";
}
?>

You might also like