After trying to find a way to change a md5 password i read that its better to generate a new one and email it.
i have the following code and for some reason its giving me this error
Notice: Undefined index: email_address on line 7
Here is the code
<?php
session_start(); // Start Session
session_register("session");
// This is displayed if all the fields are not filled in
$empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>Click <a class=\"two\" href=\"javascript:history.go(-1)\">here</a> to go back";
// Convert to simple variables 
$email_address = $_POST['email_address'];
if (!isset($_POST['email_address'])) {
?>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<label for="email_address">Email:</label>
<input type="text" title="Please enter your email address" name="email_address" size="30"/>
<input type="submit" value="Submit" class="submit-button"/>
</form>
<?php
}
elseif (empty($email_address)) {
echo $empty_fields_message;
}
else {
mysql_connect("localhost", "usern", "passw") or die(mysql_error());
mysql_select_db("mydb") 
or die(mysql_error());
$email_address = mysql_real_escape_string($email_address);
$status = "OK";
$msg="";
//error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR);
if (!stristr($email_address,"@") OR !stristr($email_address,".")) {
$msg="<p>Your email address is not in the correct format.</p>Click <a class=\"two\" href=\"javascript:history.go(-1)\">here</a> to go back"; 
$status= "NOTOK";}
echo "";
if($status=="OK"){ $query="SELECT email,username FROM users WHERE users.email = '$email_address'";
$st=mysql_query($query);
$recs=mysql_num_rows($st);
$row=mysql_fetch_object($st);
$em=$row->email_address;// email is stored to a variable
if ($recs == 0) { 
echo "<p>Sorry your address is not there in our database. Please try again.</p>Click <a class=\"two\" href=\"javascript:history.go(-1)\">here</a> to go back";
exit;
}
function makeRandomPassword() { 
$salt = "abchefghjkmnpqrstuvwxyz0123456789"; 
srand((double)microtime()*1000000); 
$i = 0; 
while ($i <= 7) { 
$num = rand() % 33; 
$tmp = substr($salt, $num, 1); 
$pass = $pass . $tmp; 
$i++; 
} 
return $pass; 
} 
$random_password = makeRandomPassword(); 
$db_password = md5($random_password); 
$sql = mysql_query("UPDATE users SET password='$db_password' 
WHERE email='$email_address'"); 
$subject = "Your New Password"; 
$message = "Hello, you have chosen to reset your password. 
New Password: $random_password 
http://www.yoursite.com/loginn
Once logged in you can change your password 
Thanks! 
Site admin 
This is an automated response, please do not reply!"; 
mail($email_address, $subject, $message, "From: yoursite.com Webmaster<admin@jyoursite.com>\n 
X-Mailer: PHP/" . phpversion()); 
echo "<p>Your new password has been send! Please check your email!";
} 
else {echo "$msg";}
}
?> 
the line its refering to is
$email_address = $_POST['email_address'];
I am not sure why this is happening, have I over seen something?
 
     
    