email; $uname = $sql -> username; } //Update database with new password $newpass = rand(10000000,99999999); $chng = "UPDATE $table_name SET password = password('$newpass'), pchange = '1' WHERE email = '$email'"; $result2 = @mysql_query($chng,$connection) or die(mysql_error()); //create message to user $msg = "

Your username & temporary password has been emailed to you.

"; $msg .= "

You must change this password immediately after your next login.

"; $msg .= "

"; $msg .= "

Login

"; //create mail message $mailheaders = "From: www$domain\n"; $mailheaders .= "Your username is $uname.\n"; $mailheaders .= "Your password is $newpass.\n"; $mailheaders .= "$base_dir/login.html"; } else { //If no email was found in the database send a notification to the admin $email = $adminemail; $msg = "

Your email address could not be located

"; $msg .="

The Website Administrator has been emailed, you should contacted by them shortly.

"; $mailheaders = "From: www$domain\n"; $mailheaders .= "A user with the email address of $_POST[email] has requested a username and password reminder.\n"; $mailheaders .= "$_POST[email] could not be located in the database.\n"; } //Email the request $to = "$email"; $subject = "Your Username & Password for www$domain"; mail($to, $subject, $mailheaders, "From: No Reply <$adminemail>\n"); ?> Username and Password Request