I am building a password reset form for my hobby site, the form itself is working beautifully. I use dreamweaver CS5, I have only posted the RELEVANT code to my question. The question has nothing to do with security.
If the password reset fails, for any reason, I want to redirect the user to a specific page. I am not sure where or how to do that in the statement the way dreamweaver generated it.
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1_reset")) {
$password_md5 = md5($_POST['password']);
$updateSQL = sprintf("UPDATE users SET password=%s WHERE username=%s AND email=%s AND security=%s",
GetSQLValueString($password_md5, "text"),
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['security'], "text")
);
mysql_select_db($database_login_form, $login_form);
$Result1 = mysql_query($updateSQL, $login_form) or die(mysql_error());
$updateGoTo = "login.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$totalRows_resetpass = mysql_num_rows($resetpass);mysql_select_db($database_login_form, $login_form);
$query_resetpass = "SELECT * FROM users";
$resetpass = mysql_query($query_resetpass, $login_form) or die(mysql_error());
$row_resetpass = mysql_fetch_assoc($resetpass);
$totalRows_resetpass = mysql_num_rows($resetpass);
?>