这是我的表格:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="register_ajax.php" method="get">
<input type="text" name="email">
<input type="submit" value="test">
</form>
</body>
</html>
这是我的 php 代码:
<?php
$dbc = mysqli_connect("localhost","root","*******","continental_tourism") OR die(mysqli_connect_error());
$email = $_GET['email'];
$query = "SELECT email FROM customer_info WHERE email = '$email' ";
$r = mysqli_query($dbc, $query) OR die(mysqli_error($dbc));
if($r)
echo "Email address exists!";
else
echo "sss";
?>
如果我输入正确的(数据库上的现有电子邮件)$r
为真。但如果我输入不存在的电子邮件,那么也是$r
如此。这是为什么?基本上我想检测空集。我该怎么做?
谢谢!