http://php.flashwebhost.com/sherly/lost_password.html
lost_password.php


Code:
<?php

if (isset($_POST['email'])) {
    $email = $_POST['email'];
} else {
    die('Please enter your email address');
}

$email = trim($email);

$db_server = '127.0.0.1';
$db_user = 'fwhphp_user';
$db_password = 'k5BJRaX6SFbs';
$db_name = 'fwhphp_db';

$mysqli = new mysqli($db_server, $db_user, $db_password, $db_name);

if ($mysqli->connect_errno) {
    echo 'Connect failed: ' . $mysqli->connect_error;
    exit();
}

$sql = "select * from users where email='$email'";

// Now time to execute the SQL statement.
$result = $mysqli->query($sql);


if ($result->num_rows == 0) {
    die("User with email address <b>$email</b> not found");
}

$name = $userInfo['name'];
$password = $userInfo['password'];
mail($email,"Your password", "Hello $name, your password is $password");

echo 'The password has been sent to the e-mail address specified;