我使用mysqli创建登录页面。在注释掉if语句以找出错误所在之后,该错误似乎在以下代码块内:
mysqli_stmt_bind_param($stmt, "ss", $mailuid, $mailuid);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
尝试运行此脚本时,出现500错误。我找不到任何语法或命名错误。
这是完整的脚本:
<?php
if(isset($_POST['login-submit'])) {
require('dbh.inc.php');
$mailuid = $_POST['mailuid'];
$password = $_POST['pwd'];
if (empty($mailuid) || empty($password)) {
header('location: ../admin.php?error=emptyfields');
exit();
} else {
$sql = "SELECT * FROM adminAccounts WHERE uid_user = ? OR email_user = ?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header('location: ../admin.php?error=sqlerror');
exit();
} else {
mysqli_stmt_bind_param($stmt, "ss", $mailuid, $mailuid);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($row = mysqli_fetch_assoc($result)) {
$pwdCheck = password_verify($password, $row['pwd_user']);
if ($pwdCheck == false) {
header('location: ../admin.php?error=wrongpassword');
exit();
} else if ($pwdCheck == true) {
session_start();
$_SESSION['userID'] = $row['id_user'];
$_SESSION['userUID'] = $row['uid_user'];
header('location: ../index.php?login=success');
exit();
} else {
header('location: ../admin.php?error=wrongpassword');
exit();
}
} else {
header('location: ../admin.php?error=nouser');
exit();
}
}
}
} else {
header('location: ../index.php');
exit();
}
任何帮助或建议将不胜感激
答案 0 :(得分:0)
在进一步测试后发现,在我的面板中,我没有启用nd_mysqli。启用该功能可以解决问题。感谢RiggsFolly的帮助