Hi and thank you for taking your time out in helping me.I have only been studying PHP for a month and I have recently
completed a login, logout and register form.
I decided to go for a forgot password form but I have no luck so far. Please help... thanks in advanced
it echo's out saying that I have sent an email with the password, but i still do not receive anything
ERROR MESSAGE:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
if (isset($_POST['submit']))
{
mysql_connect("localhost", "username", "password") or die("could not connect to the database");
mysql_select_db("db_name") or die("could not select database");
$username = $_POST['username'];
$email = $_POST['email'];
$sql = mysql_query("SELECT * FROM `users` WHERE `username` = '$username' AND `email` = '$email'");
$result = mysql_num_rows($sql);
if (!$result)
{
die (mysql_error());
}
if ($result == 1)
{
$rows = mysql_fetch_array($result);
$password = $rows['password'];
$email = $rows['email'];
$subject ="Password request";
$header = "from: omarmuzaffar@live.co.uk";
$body = "Your password is " . $password;
mail ($email, $subject, $header, $body);
print("an email containning the password has been sent to you");
}else
{
echo ("No such user exists in the system. Please try again");
}
}
?>