我有更新帐户信息的表单。在一种形式下,我有姓名,用户名,电子邮件,公司,密码。比方说,我想要做的就是改变我的名字,我仍然使用这种形式,所有其他领域保持不变。在更新表单中,我有一个电子邮件和用户名检查程序,确保它们尚未被使用。所以现在,即使我不更改我的电子邮件地址或用户名,它也会被提交给检查代码。如何防止第二次重复检查?
如何解决它,这样它不会阻止它,如果它属于同一个人:
// checks if the email is in use
if (!get_magic_quotes_gpc()) {
$_POST['email'] = addslashes($_POST['email']);
}
$emailcheck = $_POST['email'];
$check = mysql_query("SELECT email FROM accounts WHERE email = '$emailcheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
print("here i basically show the form once again highlighting the error)");
die('');
}
在旁注;你希望在列上使用'UNIQUE'索引吗? – Wrikken 2011-03-30 20:02:18