Password recovery form
require "database.php";
$action = (isset($_POST['action'])) ? $_POST['action'] : "";
$name = (isset($_POST['name'])) ? $_POST['name'] : "";
$email = (isset($_POST['email'])) ? $_POST['email'] : "";
$from = 'info@ib-sm.org';
if ($action == "sendpassword")
{
$main_query = "select * from `users` where `email`='$email'";
$main_result = $foo->query($main_query);
$num_rows = $foo->numrows($main_result);
if ($num_rows > 0)
{
for ($i = 0; $i < $num_rows; $i++)
{
$password = $foo->result($main_result, $i, 'password');
$mailTo = "$email";
$mailSubject = "Lost password ib-sm.org";
$mailHeader = "From: International Business-Society Management <$from>";
$message = "Dear $name,\n\n";
$message .= "You have asked to resend your password.\n\n";
$message .= "Your password is: $password\n\n";
mail($mailTo, $mailSubject, $message, $mailHeader);
print "
\n";
print "You password is send to $email.
\n";
print "
Login\n";
}
}
}
else
{
?>
Please fill out the form below to have your password retrieved and emailed to you.