The submit button in my script isn't working, and I can't figure out why.... Hoping new eyes will help out?
Code: Select all
<?php
require_once ('../../files/config.inc');
$page_title = 'Forgot Your Password';
include_once ('header.html');
include ('registerfunc.php');
define("ROOT_DIR","/home/virtual/abcabcabcabc.com/var/www/html/");
if (isset($_POST['submit'])) {
require_once ('../../files/mysql_connect.php');
if (empty($_POST['username'])) {
$u = FALSE;
echo '<p><font color="red" size="1">You forgot to enter your username</font></p>';
} else {
$u = escape_data($_POST['username']);
//Check for the existence of that username
$query="SELECT UserID, UserEmail FROM users where username='$u'";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);
if ($row) {
$uid = $row[0];
$email = $row[1];
} else {
echo '<p><font color="red" size="1">The submitted username does not match those on file!</font></p>';
$u = FALSE;
}
}
//If everything is OK
if ($u) {
//Create a new random password
$p = substr(md5(uniqid(rand(),1)),3,10);
//Make the query
$query = "UPDATE users SET password=PASSWORD('$p') WHERE user_id=$uid";
$result = @mysql_query ($query);
if (mysql_affected_rows() == 1) {
addpasswd(ROOT_DIR.$u."/admin/", $u, $u, $p);
$body = "Your password to log into abcabcabcabc.com has been temporarily changed to '$p'. Please login using this password and your
username. At that time you may change your password to something more familiar.";
mail ($email, 'Your temporary password', $body, 'From: admin@abcabcabcabc.com');
echo '<h3>Your password has been changed. You will receive the new, temporary password at the email address with which you registered. Once you hav
e
logged in with this password, you may change it by clicking on the "Change Password" link.</h3>';
include('footer.html');
exit();
} else {
$message = '<p><font color="red" size="1">Your password could not be changed due to a system error.</font></p>';
}
mysql_close();
} else {
echo '<p><font color="red" size="1">Please try again.</font></p>';
}
}
?>
<h1>Reset your password</h1>
<p>Enter your username below and your password will be reset.</p>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset>
<p><b>User Name:</b>
<input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>"></p>
</fieldset>
<div align="center">
<input type="submit" name="submit" value="Reset My Password"></div>
</form>
<?php
include ('footer.html');
?>