我正在使用pdo
代码来处理我的页面上的多级用户登录,并在测试后收到此错误:
PDO::errorInfo(): Array ( [0] => 00000 [1] => [2] => )
我已经检查了很多次代码,但仍然找不到任何错误。如果有人可以解释该错误并指出我的代码中是否存在任何错误,我将不胜感激:
<?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 "\nPDO::errorInfo():\n";
print_r($conn->errorInfo());
}
}
?>