我想通过检查表上是否已经存在用户的电子邮件来检查用户是否已经存在于我的“卖家”表中。如果存在,我想跳过插入新记录,否则插入新卖家。代码如下:
$email = $_REQUEST['semail'];
$sql = 'SELECT Email FROM project2.sellers WHERE Email = :email';
$s = $pdo->prepare($sql);
$s->bindValue(':email', $email);
$s->execute();
if (!$s) {
}
if (mysql_num_rows($s)!=0) {
echo "exists";
}
else
{
$sql = 'INSERT INTO project2.sellers SET
Type = :stype;
Name = :sname;
Email = :semail;
Phone = :sphone;
Location = :location;
City = :city';
$s = $pdo->prepare($sql);
$s->bindValue(':stype', $_REQUEST['stype']);
$s->bindValue(':sname', $_REQUEST['sname']);
$s->bindValue(':semail', $_REQUEST['semail']);
$s->bindValue(':sphone', $_REQUEST['sphone']);
$s->bindValue(':location', $_REQUEST['location']);
$s->bindValue(':city', $_REQUEST['city']);
$s->execute();
}
header('location: ../'.$_REQUEST['category']);
请告诉我我哪里错了