如何检查电子邮件是否已被使用?如果正在使用,用户会收到电子邮件已被使用的警告,如果没有,则会继续。PHP检查电子邮件是否已被使用
这里在我的代码,它没有工作,它仍然登记,即使我输入了相同的电子邮件。
<?php
session_start();
[email protected]_connect("localhost","root","secretpassword");
$dbcheck = mysql_select_db("buybranded");
if (!$dbcheck) {
echo mysql_error();
}
$new_email= $_POST['email'];
$xxx = mysql_query("SELECT email FROM users WHERE email = $new_email");
$yyy = mysql_fetch_row($xxx);
if(!isset($yyy['email'])){
$hashed_password = hash('sha512', $_POST['password']);
$type="customer";
$sql="INSERT INTO users(first_name, middle_name, last_name, gender, email, password, birth_date, home_address, postal_code, home_phone, mobile_phone, source, type)
VALUES
('$_POST[first_name]','$_POST[middle_name]','$_POST[last_name]','$_POST[gender]','$_POST[email]','$hashed_password','$_POST[birth_date]','$_POST[home_address]','$_POST[postal_code]','$_POST[home_phone]','$_POST[mobile_phone]','$_POST[source]','$type')";
}
else {
echo "hahaha";
}
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error($con));
}
header('refresh: 0; url=../index.php#openModal');
$message = "You are now Registered, Please Sign In.";
echo("<script type='text/javascript'>alert('$message');</script>");
?>
我希望你们能帮助,我是新用PHP。 :) 谢谢!
你真的,因为它是过时不应该使用'mysql_'功能的新项目。改为使用mysqli或PDO。 – TheWolf 2014-10-03 14:19:58
并且不要发布密码! – Jost 2014-10-03 14:20:24
当我在你的电子邮件输入'1或1 = 1'中输入时会发生什么? – Daan 2014-10-03 14:21:20