【发布时间】:2014-03-15 18:27:22
【问题描述】:
我一直在努力解决我的数据库中的“检查电子邮件是否存在问题”。整个功能就是为您的帐户更改您的电子邮件地址。
我想检查我的数据库中是否已经存在该电子邮件地址。我想你只要看看我的代码就知道我在追求什么:
if($_POST["changeemail2"]=="Send request")
{
$newemail=$_POST["newmail"];
$sql="SELECT email FROM tbluser";
$result=$objMysql->query($sql);
while($dbmails = mysql_fetch_assoc($result))
{
if(in_array($newmail, $dbmails) && empty($_SESSION["emailerror"]))
{
$_SESSION["emailerror"]="That e-mail address<br />is already in use.";
}
}
if(empty($newemail))
{
$_SESSION["emailerror"]="You didn't select<br />a new e-mail address";
}
if($_SESSION["emailerror"]=="")
{
$oldemail=$_SESSION["user"]["email"];
if($objMysql->sendchangeEmail($oldemail, $newemail))
{
$_SESSION["emailsuccess"]="E-mail verification has been sent to your current e-mail.";
$code="success";
}
}
}
我尝试了很多不同的方面,但我的大脑现在无法正常工作。
【问题讨论】:
-
@Rahil:请不要为了应用不同的编码标准而重新格式化代码。一般来说,这可能会意外地掩盖有问题的错误,并且无论如何编码标准的选择都是主观的。谢谢!