有人可以帮助我吗?我一直在尝试在工作的登录页面上使用准备好的语句,但是没有成功。我不断出错。以下是我开始尝试准备好的语句之前的“最后工作页面”的一部分。任何帮助将不胜感激。
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from form
$myusername=mysqli_real_escape_string($db,$_POST['username']);
$mypassword=mysqli_real_escape_string($db,$_POST['password']);
$sql="SELECT * FROM user WHERE username='$myusername' and password='$mypassword'";
$result=mysqli_query($db,$sql);
$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
$active=$row['active'];
$count=mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
$_SESSION['login_user']=$myusername;
header("location: homepage.php");
}
else
{
$error="Your Login Name or Password is invalid";
}
}