I'm trying to make a simple reset password form where the user enters their username, email address, a new password and confirms the new password. However, nothing happens when I run the page. Below is the form that I'm using as well as the PHP script.
FORM:
<form method="POST" action="password.php">
<table>
<tr>
<td>Enter your Email</td>
<td><input type="text" size="60" name="email"></td>
</tr>
<tr>
<td>Enter your UserName</td>
<td><input type="text" size="30" name="username"></td>
</tr>
<tr>
<td>Enter your new password:</td>
<td><input type="password" size="30" name="newpassword"></td>
</tr>
<tr>
<td>Re-enter your new password:</td>
<td><input type="password" size="30" name="confirmnewpassword"></td>
</tr>
</table>
<p><input type="submit" value="Update Password">
</form>
PHP SCRIPT
<?php require_once('Connections/register.php'); ?>
<?php
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$confirmnewpassword = $_POST['confirmnewpassword'];
// Redirect links for when password reset is successful or not.
$MM_passwordResetSuccess = "password-updated.php";
$MM_passwordResetFailed = "reset-password.php";
$result = mysql_query("SELECT * FROM register WHERE
username='$username' AND email='$email'");
if(!$result)
{
echo "The username or email you entered does not exist";
}
if($password == $confirmnewpassword)
$sql=mysql_query("UPDATE register SET password='$password' where
username='$username' AND email='$email'");
if($sql)
{
header("Location: " . $MM_passwordResetSuccess );
//echo "Congratulations You have successfully changed your password";
}
else
{
header("Location: ". $MM_passwordResetFailed );
//echo "Passwords do not match";
}
?>
Can anyone help?
error_reporting (E_ALL);as your first line.$_POST['password'];should be$_POST['newpassword'];- so you get an'UNDEFINED INDEX ERROR'