Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /restore.php on line 9
<?php
include_once("../../include/dbconnect.php");
$email = $_POST['email'];
$title = "Password Restoring";
if (empty($email)){
echo "Enter Email";
} else {
$restoreCheck = mysql_query("SELECT * FROM p286168_reserv.`people` WHERE `mail` = '$email'", $connect) || die(mysql_error());
$restoreArray = mysql_fetch_array($restoreCheck) || die(mysql_error());
if (empty($restoreArray)) {
echo "You are not registred";
} elseif (mysql_num_rows($restoreCheck) > 0) {
$chars = "qazxswedcvfrtgbnhyujmkiolp1234567890QAZXSWEDCVFRTGBNHYUJMKIOLP";
$max = 10;
$size = StrLen($chars)-1;
$password = null;
while($max--) {
$password.=$chars[rand(0,$size)];
}
$hashedPassword = md5($password);
$message = "Your new password: $password";
if (mail($email, $title, $message)) {
mysql_qury("UPDATE `people` SET `password` = '$hashedPassword' WHERE `mail` = '$email'");
echo "New password sent";
} else {
echo "We are unable to send message";
}
}
}
?>
// or вместо ||
$restoreCheck = mysql_query("SELECT * FROM p286168_reserv.`people` WHERE `mail` = '$email'", $connect) or die(mysql_error());
`mail` = '$email'
, т.к. $email
не фильтруется, а берется напрямую из $_POST
.