所有
我想检查用户提交的电子邮件是否已存在于我的数据库中。我挣扎着代码(多年来没有写任何东西):
//Assign variables based on the form submitted
$name = $_POST['name'];
$email = $_POST['email'];
$newsletter = $_POST['newsletter'];
//check if email is unique
$query = "SELECT SELECT * FROM Members WHERE member_email='$email'";
$result = mysql_query($query);
if($result)
{
//Generate password function above
}
else
{
//Do something
}
它经常说电子邮件已经注册,尽管情况并非如此。
会感激一些指点!
谢谢!
EDIT ---------------
出现此错误:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /var/sites/g/site/public_html/Registered.php on line 25
来自编辑过的代码:
//check if email is unique
$query = "SELECT SELECT * Members WHERE member_email='$email'";
$result = mysql_num_rows(mysql_query($query));
if($result == 0)
{
//Do something
}
else
{
//Duplicate
}