When i use the code below i get a very strange error:
Unknown has generated errors and will be closed by windows. You will need to restart the program
Now what the code does is find a users email address or username in the database and saves a new password for them and emails it to thier email address if they have forgot their old password. This works fine if the user does exist in the database, however if the users email address or username is not entered properly then it comes up with that strange error dialog box. How can i solve this problem.
Thanks
<?php
if ($_GET['forgot_action']=="submit"){
$uname = mysql_escape_string($_POST['uname']);
$email = mysql_escape_string($_POST['email']);
$newpass = rand();
$newpassmd5 = md5($newpass);
$forgot_sql = "UPDATE clients SET password='$newpassmd5' WHERE username='$uname' OR email='email'";
$forgot_result = mysql_select_db("$db_name");
mysql_query("$forgot_sql");
if ($forgot_result){
$forgot_info = "SELECT username,email FROM clients WHERE username = '$uname' OR email = '$email'";
$forgot_info_result = mysql_query($forgot_info);
$forgot_info_number = mysql_num_rows($forgot_info_result);
$forgot_info_row = mysql_fetch_assoc($forgot_info_result);
$send_email = $forgot_info_row['email'];
$username = $forgot_info_row['username'];
if ($forgot_info_result){
mail("$send_email","Requested Information","This is an automatic response for the information you requested.
Username: $username
Password: $newpass");?>
<span class="maintext">A new password has been sent to <?php echo $forgot_info_row['email']; ?>.</span>
<?php
}
else{
echo ("Incorrect details.");
}
}
}
?>