我正在尝试制作一个登录系统,并且代码似乎在与assoc有关的if语句的开始处停止。
我尝试更改输入的参数,但似乎无济于事。
<?php
$value1 = $_POST['uname'];
$value2 = $_POST['pwd'];
if (isset($_POST['loginbtn'])) {
//completes all of the code, only if the login button has been pressed
require 'creationlink.php';
//connects to database
if (empty($value1) || empty($value2)) {
header("Location: index.php?error=emptyfields");
exit();
}
//checks no fields are blank
else {
$sql = "SELECT * FROM loginTable WHERE username=?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: index.php?error=sqlerror");
exit();
} else {
mysqli_stmt_bind_param($stmt, "ss", $value1, $value1);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
if ($row = mysqli_fetch_assoc($result)) {
$pwdcheck = password_verify($value2, $row['password']);
if ($pwdcheck == false) {
header("Location: index.php?error=wrongpassword");
exit();
} else if ($pwdcheck == true) {
session_start();
$_SESSION['userID'] = $row['loginID'];
$_SESSION['username'] = $row['username'];
header("Location: index.php?error=success");
exit();
} else {
header("Location: index.php?error=wrongpassword");
exit();
}
} else {
header("Location: index.php?error=nouser");
exit();
}
}
}
mysqli_stmt_close($stmt);
mysqli_close($conn);
//closes connection
} else {
header("Location: index.php?error=nonononono");
exit();
}
?>
我希望该程序允许用户登录(如果他们具有正确的详细信息)。
该程序应返回首页,并在URL中显示成功消息