Change Password,php
#1

Can one tell me where the error is

 

<?php

include("include/config.php");

// connect to the mysql server
$link = mysql_connect($ip, $userdb, $sqlpw)
or die ("Could not connect to mysql because ".mysql_error());

// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());

$username = $_POST[username];
$password = $_POST[password];
$newpassword = $_POST[newpassword];
$confirmnewpassword = $_POST[confirmnewpassword];

$result = mysql_query("SELECT password FROM users WHERE username=$username");
if(!$result)
{
echo "The username you entered does not exist. <a href=change_pw.php>Try Again</a> or <a href=index.htm>Quit</a>";
}
else
if($password!= mysql_result($result, 0))
{
echo "You entered an incorrect password. <a href=changepw.htm>Try Again</a> or <a href=index.htm>Quit</a>";
}
if($newpassword=$confirmnewpassword)
$sql=mysql_query("UPDATE users SET password=$newpassword where username=$username");
if($sql)
{
echo "Congratulations! You have successfully changed your password. <a href=index.php>Continue</a>";
}
else
{
echo "The new password and confirm new password fields must be the same. <a href=change_pw.php>Try Again</a> or <a href=index.php>Quit</a>";
}
?>

 



Messages In This Thread
[No subject] - by crankchaos - 04-05-2013, 06:27 PM
[No subject] - by crankchaos - 04-05-2013, 06:30 PM
[No subject] - by luoo - 04-05-2013, 09:36 PM
[No subject] - by Sentence - 04-10-2013, 07:23 PM
[No subject] - by Wizatek - 04-11-2013, 03:33 AM
[No subject] - by Gothic - 04-11-2013, 06:32 AM
[No subject] - by Wizatek - 04-11-2013, 09:34 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)