您好我是mysql编码的新手,
我正在尝试用php和mysql创建一个登录系统。 只有我现在得到2个错误,我不知道如何解决它们。 如果你可以帮助我,我会感激不尽。
错误讯息: 警告:mysqli_num_rows()要求参数1为mysqli_result,布尔值在第19行的/storage/ssd4/235/5867235/public_html/htmlenphp/login.inc.php中给出
警告:无法修改标头信息 - 已经发送的标头(/storage/ssd4/235/5867235/public_html/htmlenphp/login.inc.php:19上的输出)/ storage / ssd4 / 235/5866735 / public_html /htmlenphp/login.inc.php在第21行。
这是我的PHP代码:
<?php
在session_start();
if (isset($_POST['submit'])) {
include 'dbh.inc.php';
$uid = mysqli_real_escape_string($conn, $_POST['uid']);
$pwd = mysqli_real_escape_string($conn, $_POST['pwd']);
if (empty($uid) || empty($pwd)) {
header("Location: index.php?login=empty");
exit();
} else {
$sql = "SELECT * FROM users WHERE user_uid='$uid'";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck < 1) {
header("Location: index.php?login=error");
exit();
} else {
if ($row = mysqli_fetch_assoc($result)) {
$hashedPwdCheck = password_verify($pwd, $row['user_pwd']);
if ($hashedPwdCheck == false) {
header("Location: index.php?login=error");
exit();
} elseif ($hashedPwdCheck == true) {
$_SESSION['u_id'] = $row['user_id'];
$_SESSION['u_first'] = $row['user_first'];
$_SESSION['u_last'] = $row['user_last'];
$_SESSION['u_email'] = $row['user_email'];
$_SESSION['u_uid'] = $row['user_uid'];
header("Location: index.php?login=succes");
exit();
}
}
}
}
} else {
header("Location: index.php?login=error");
exit();
}