PDO查询不成功!
代码如下:
<html><br /><meta type="text/html" charset=utf8><br /><form action="form.php" method="POST"><br /><p>名字: <input type="text" name="name" /></p><br /><p>密码: <input type="password" name="password" /></p><br /><input type="submit" /><br /></form><br /><?php<br /> error_reporting(0);<br /> $dsn = "mysql:host=localhost;dbname=liuyan";<br /> $db = new PDO($dsn, 'root', 'root');<br /> $name = $_POST['name'];<br /> $password = md5($_POST['password']);<br /> //$date = date("Y-m-d H:i:s");<br /> $sql = "select * from admin where user_name=? and password=?";<br /> $stm = $db->prepare($sql);<br /> $stm->execute(array($name,$password));<br /> $rs=$stm->fetch();<br /> var_dump($rs);<br /> if(empty($rs)){<br /> echo "<script>alert('查询失败');</script>";<br />} else{<br /> echo "<script>alert('查询成功');</script>";<br />}<br /> ?><br /></html>