这是我的连接脚本。我在另一个页面上有一个表单,它带有用户的用户名和密码。我不明白为什么它总是说错误的密码或用户名。
<?php
include('functions.php');//*functions = working
$user = $_POST['user'];
$pass_hash = md5($_POST['pass']);
$bdd = connPDO();
connPDO();//*DB connection functions = working
$req = $bdd->prepare('SELECT Id FROM users WHERE pseudo = :user AND pass =
:pass');
$req->execute(array(
'user' => $user,
'pass' => $pass_hash));
$result = $req->fetch();
if (!$result)
{
echo 'Wrong username or password !';
}
else
{
session_start();
$_SESSION['id'] = $resultat['id'];
$_SESSION['user'] = $user;
echo 'You have successfully logged in !';
}
?>
答案 0 :(得分:1)
您在参数中忘记了:
:
$req->execute(array(
':user' => $user,
^----here
':pass' => $pass_hash));
^----here