好吧,出于某种原因,如果不这样做,我总是会收到该电子邮件。
public function emailExists($mail) {
$handler = new sql();
$sql = $handler->connect();
$sql->real_escape_string($mail);
$result = $sql->query("SELECT email FROM users WHERE email='".$mail."'");
if($result->num_rows != 0) return true;
else {
$handler->log_write($mail, "register_fail","NULL");
return false;
}
$sql->close();
return false;
}
现在是支票
if($user->emailExists() == false) {
$user->create($name, $pass, $email, $age, $gender);
jquery_alert("You have been registered. Thank you for using our services. Enjoy your stay!");
jquery_reload();
}
else {
jquery_alert("This email already exists");
}
答案 0 :(得分:3)
将电子邮件地址作为方法中的参数传递。
if($user->emailExists($email) == false) {
// your code here
}
答案 1 :(得分:0)
在您的函数中,返回的默认值为false
并在您的方法中传递电子邮件地址。
试试这个解决方案
if($user->emailExists($email) == true) {
$user->create($name, $pass, $email, $age, $gender);
jquery_alert("You have been registered. Thank you for using our services. Enjoy your stay!");
jquery_reload();
}
else {
jquery_alert("This email already exists");
}