$KEY = "something really long long long long long and secret";
$hash = $_GET['hash'];
$user_id = $_GET['id'];
$timestamp = $_GET['timestamp'];
if ($hash == md5( $user_id . $timestamp . $KEY ))
{
if ( time() - $timestamp > 3600 ) // one hour
{
die('link expired');
}
}
else
{
die('invalid parameters');
}
//validation passed
if ($_POST['new_password'])
{
reset_user_password($user_id, $_POST['new_password']);
die(' password changed successfully ');
}
else
{
echo '
<form action="reset-password-form.php?hash=$hash&id=$user_id×tamp=$timestamp" method="post">
new password: <input type="password" name="new_password">
<input type="submit" value="submit">
</form>
';
}
|