大家好我是PHP的新手,想要创建登录/注册。我想通过电子邮件检查用户是否已经存在。
但是我收到了这个错误:
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
这是我的PHP代码:
<?php
require "init.php";
$vorname = $_POST ["vorname"];
$nachname = $_POST ["nachname"];
$geburtstag = $_POST ["geburtstag"];
$geschlecht = $_POST ["geschlecht"];
$email = $_POST ["email"];
$namedeinerschule = $_POST ["namedeinerschule"];
$benutzername = $_POST ["benutzername"];
$passwort = $_POST ["passwort"];
$sql = "select * from user_info where email like '".$email."';";
$result = mysqli_query($con,$sql);
$response = array();
if (mysqli_num_rows($result)>0)
{
$code = "reg_faild";
$message = "User already exist";
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode($response);
}
else
{
$sql = "insert into user_info values ('".$vorname."','".$nachname."','".$geburtstag."','".$geschlecht."','".$email."','".$namedeinerschule."','".$benutzername."','".$passwort."');"; //speicherung
$result = mysqli_query($con,$sql);
$code = "reg_success";
$message = "Thank your for register with us. Now you can login.";
array_push($response,array("code"=>$code, "message"=>$message));
echo json_encode($response);
}
mysqli_close($con);
?
>
有人能帮助我吗?