I'm using pdo
code to process my multilevel users login on my page and got this error after testing:
PDO::errorInfo(): Array ( [0] => 00000 [1] => [2] => )
I have checked my code many times and still can't figure out any mistake. I would appreciate if anyone could explain the error and point out if there are any mistake in my code here:
<?php
include("db.php");
session_start();
if (isset($_POST['submit'])){
$user=$_POST['username'];
$pass=$_POST['password'];
$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES,false);
$query=$conn->prepare("select * from users where username=:user and password=:pass");
$query->BindParam(":user",$user);
$query->BindParam(":pass",$pass);
$query->execute();
if ($query->rowCount()>0){
session_start();
$data=$query->fetch();
if($data['position']=="kc"){
$_SESSION['username']=$data['username'];
$_SESSION['position']=$data['position'];
header('location:index.php');
}else{
$_SESSION['username']=$data['username'];
$_SESSION['position']=$data['position'];
header('location:index.php');
}
}
else{
echo "
PDO::errorInfo():
";
print_r($conn->errorInfo());
}
}
?>