$username = $_POST['username'];
$password = $_POST['password'];
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$query .= "SELECT balance FROM users WHERE id ='1'";
if (mysqli_multi_query($connect, $query)) {
do {
/* store first result set */
if ($result = mysqli_store_result($connect)) {
while ($row = mysqli_fetch_row($result)) {
if($row['username'] == $username && $row['password'] == $password && $password != '' && $username != ''){
session_start();
$_SESSION['username'] = $row['username'];
$_SESSION['email'] = $row['email'];
$_SESSION['balance'] = $row['balance'];
echo "Logged in successfully!";
} else {
echo "Invalid username or password!";
}
}
mysqli_free_result($result);
}
} while (mysqli_next_result($connect));
}
当他们发布你得到的用户名/密码时,我不确定如何将人员信息保存在会话变量中(我认为这是正确的做事方式),其他信息在他们的行上。
截至目前,我甚至无法输入检查用户名和密码的if语句