hi, i have a change password script that is giving me an error when i submit the email and password and hit submit. any help is GREATLY appreciated. here is the error i get
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hermes/bosweb/web173/b1739/sl.brendansite1/public_html/OLDMASTERCOPIES/passrecovery8.php on line 38
That email does not exist in the database
and here is the code to my page
Code:
<?php
include("connect1.php");
ini_set('display_errors', 1);
error_reporting(E_ALL); // GREAT SNIPPET FOR DEBUGGING OUTPUTS ERRORS TO SCREEN */
if (isset($_POST['email']) && isset($_POST['Password']) && isset($_POST['Confirm']))
{
// Declare Variables
$email = mysql_real_escape_string($_POST['email']);
$Password = mysql_real_escape_string($_POST['Password']);
$Confirm = mysql_real_escape_string($_POST['Confirm']);
// Encrypt passwords with md5 encryption
$Password = md5($Password);
$Confirm = md5($Confirm);
if($Password != $Confirm)
{
echo "<br>The two passwords did not match<br>";
echo "Please enter your email: <form action=\"passrecovery8.php\" method=\"POST\" >
<input type=\email\" name=\"email\"><br>
<br>
<br><br><br>Please enter your new password:<br>
<input type=\"password\" name=\"Password\"><br>
<br>
Please Confirm that new Password:<br>
<input type=\"password\" name=\"Confirm\"><br>
<br><input type=\"submit\" value=\"Set Password\"</form>";
exit;
}
// Check if the email already exists in database
$query = "SELECT * FROM members_videos WHERE Email = '$email' ";
$results = mysql_num_rows(mysql_query($query));
if ($results > 0)
{
// Insert information to the database
mysql_query("UPDATE members_videos SET Password='$Password' WHERE Email='$email'");
//Send them to login
header("Location:http://oldmastercopies.com/success.html");
}
else
{
echo "<br>That email does not exist in the database<br>";
}
}
else
{
// Displaying Forms
echo "Please enter your email: <form action=\"passrecovery8.php\" method=\"POST\">
<input type=\"text\" name=\"email\"><br>
<br>
<br><br>Please enter your new password:<br>
<input type=\"password\" name=\"Password\"><br>
<br>
Please Confirm that new Password:<br>
<input type=\"password\" name=\"Confirm\"><br>
<br><input type=\"submit\" value=\"Set Password\"></form>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reset Password Page</title>
</head>
<body>
</body>
</html>
|