这是我网站的代码。它旨在注册新用户,只有登录的管理员才能执行此操作。该帐户已成功创建,但它似乎没有为 mysqli_num_rows 返回 1。我打印了 num_rows 返回的值,但没有任何结果,甚至没有 0。我已经为此工作了好几天,我对 php 编码非常陌生,所以这可能是一个明显的错误,但我看不到它。任何帮助将不胜感激。我有搜索谷歌,但找不到任何东西。
if($_SERVER['REQUEST_METHOD']=="POST"){
$name = mysqli_real_escape_string($_POST['fname']);
$email = mysqli_real_escape_string($_POST['email']);
$user = mysqli_real_escape_string($_POST['user']);
$pass = mysqli_real_escape_string(md5($_POST['password']));
$authority = mysqli_real_escape_string($_POST['use']);
$queryCheck = "SELECT `user` FROM `user` WHERE `user`='$user';";
$resultCheck = mysqli_query($link, $queryCheck);
$rowCheck = mysqli_num_rows($resultCheck);
if($rowCheck != 1){
$query = "INSERT INTO `user` (`id`, `name`, `email`,`user`,`pass`) VALUES ($authority,'$name','$email','$user','$pass');";
//echo $query;
$result = mysqli_query($link, $query);
$row = mysqli_affected_rows($result);
if($row == 1){
echo "User Created Successfully!<br/>";
echo '<br/><br/><br/><a href="admin.php">Return to Administration Page</a>';
}else{
echo "User was not created, Please try again.";
}
}else{
echo 'User already exists.';
}
}