【发布时间】:2016-04-02 12:35:55
【问题描述】:
在检查数据库中是否已存在电子邮件时遇到问题。
<?php
session_start();
include_once("connection.php");
$handler = new Connection;
$handler = $handler->connect();
$email = $_POST['email'];
$check = $handler->prepare("SELECT * FROM emailcollector WHERE email=':mail'");
$check->execute(array(':mail' => $email));
if($check->rowCount > 0){
header("Location: yes.php");
}else{
header("Location: no.php");
}
?>
我正在使用 pdo 连接到数据库。当我运行代码时,它总是说它不存在。我对此有点陌生。感谢您的帮助
【问题讨论】:
-
在此处删除引号
email=':mail'它将是email=:mail -
@Saty,还是不行
-
现在你遇到了什么错误??
-
不要报错,它只是跳转到 no.php 所以它做了 $check->rowCount 等于 0,这意味着该电子邮件不存在。
-
是的,可能是。检查电子邮件是否存在于您的数据库中??