为什么我无法登录到我的index.php页面,它只是在我的login.php页面中被删除。请帮忙。谢谢。PHP登录无法登录到index.php
<?php
session_start();
$conn = new PDO('mysql:host = localhost;dbname=userdb','root','');
if (isset($_POST['login'])){
$username = $_POST['username'];
$password = $_POST['password'];
$query = $conn->prepare("SELECT COUNT('userID') FROM 'tbl_account' WHERE 'username' = '$username' AND 'password' = '$password' ");
$query->execute();
$count = $query->fetchColoumn();
if ($count == 1){
$_SESSION['username'] = $username;
header("location : index.php");
exit();
}else{
$error = "Your Login Name or Password is invalid";
}
}
?>
<html>
<head>
<title>Login</title>
</head>
<body>
<form action = "?" method = "POST">
<input type = "text" name="username"><br> //username
<input type = "password" name = "password"><br> //password
<input type = "submit" name = "submit" value = "Login"> /button
</form>
</body>
</html>
哪里可能是我的错?在我的PDO上?在我准备好的声明? TIA
自动换行关行情形成的表和列名,而不是使用反引号。并且必须阅读http://php.net/manual/en/pdostatement.bindparam.php – Saty
我爱你准备好的声明。 – revo