爲什麼我無法登錄到我的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