I have been struggling with a "check if e-mail exists-problem" in my database. The whole function is about changing your e-mail address for your account.
I want to check if the e-mail address already exists in my database. I guess you'll know what I'm after if you just check my code:
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";
}
}
}
I have tried many different aspects but my brain is just not working right now.