PHP表单电子邮件验证

时间:2015-01-10 01:53:13

标签: php html forms

我正在创建一个忘记密码页面,当用户点击忘记密码并输入他/她的电子邮件地址时,链接被发送到他/她的电子邮件我的代码工作正常,但电子邮件进入垃圾邮件/垃圾文件夹。

任何人都可以帮助我为什么会发生这种情况?

这是我的代码

<?php
$remail = mysqli_real_escape_string($con,$_REQUEST['name']);
if (!filter_var($remail, FILTER_VALIDATE_EMAIL)) // Validate email address
{
$message =  "Invalid email address please type a valid email!!";
}
else
{
$query = "SELECT id FROM users where email='".$remail."'";
$r = mysqli_query($con,$query);
$Results = mysqli_fetch_array($r);
if(count($Results)>=1)
{
$encrypt = $Results['id'];
$encrypt=md5(sha1(md5($encrypt)));
$message = "Your password reset link send to your e-mail address.";
$to=$remail;
$subject="Forget Password";
$from = 'miniface';
$body='Hi, <br/> <br/>Your Email is '.$_REQUEST['name'].' <br><br>Click here to reset your password http://link.com'.$encrypt.'&action=reset   <br/> <br/>--<br>miniface.com<br>Solve your problems.';
$headers = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($from) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to,$subject,$body,$headers);
else
{
$message = "Account not found please signup!";
}
}

echo $message;
?>

0 个答案:

没有答案