Here is my connection script. I have a form on another page which brings the username and password of the user. I don't get why it always says wrong password or username.
<?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 !';
}
?>
You forgot :
in the parameters:
$req->execute(array(
':user' => $user,
^----here
':pass' => $pass_hash));
^----here