<?php
If(isset($_POST['submit']))
{
$name=$_POST['user'];
require('connect.php');
global $pdo;
$stmt= $pdo->prepare("select name from user where name=?");
$stmt->bindparam(1,$name);
$stmt->execute();
$row=$stmt->fetch(PDO::FETCH_ASSOC);
if($row==false)
{
die("erorr".print_r($stmt));
}
elseif($row['name']==$name)
{
header("location: mypage.php");
}
else
{
die("please enter your user name and password");
}
}
?>
error- code PDOStatement Object ( [queryString] => select name from user where name=? ) erorr1 check my code help me
maybe there is no errors.
replace
die("erorr".print_r($stmt))
by this:
$err=$stmt->errorInfo();
die('error :'.$err[2]);
So far, the possible problem are table (or fields) in the query does not exists, or the $name
has no match in the table. Maybe you have to check the value in $stmt->rowCount