Hi all,
Ive created a pretty simple user system its all working well users can sign up and so on. Though i wanted to add extra security to this system so when the user wants to modify their password it asks for their old password otherwise they cant sign up for a new password.
Im using two files for this the modify.php file where the user can fill in their password and old password. And the User.php containing the if statement.
I think ive done the IF statement but im not sure because the variable which will show the error message i cant seem to get working so that it displays the message on the other page.
Heres the code which powers the form(sorry for the messy coding its late and i just really want to get this finished!):
function modifyUser()
{
$userId = (int)$_POST['hidUserId'];
$password = md5($_POST['txtPassword']);
$oldpass = md5($_POST['txtOldPass']);
$oldpassdata = mysql_query("SELECT user_password FROM tbl_user WHERE user_id = '$userId'");
if ($oldpass==$oldpassdata)
$sql = "UPDATE tbl_user
SET user_password = '$password'
WHERE user_id = '$userId'";
dbQuery($sql);
header('Location: index.php');
else
$errorpass= "Oldpassword does not match!";
}
The $errorpass varible is what i want to display on the form page, so that the error is displayed on the form.
I have tried using using the echo function to display the varible but its not picking it up from the otherpage
<td class="content"> <input name="txtOldPass" type="password" class="box" id="txtOldPass" size="20" maxlength="20"><?php echo $errorpass; ?></td></tr>
I hope you can help, thanks for your time.