我已经在互联网上搜索了有关此内容的帮助,但找不到任何内容。显然,我是唯一遇到此问题的人。
我的网站上有一个从一开始就起作用的网络表单。最近,托管我的网站的服务器通知我即将停止对php 5.6的支持,并且我将必须更新到7.2。所以我做到了,现在电子邮件表单的行为就像正常的一样,例如错误地填写它会像以前一样显示错误消息,正确地填写它会像正常一样显示“谢谢”页面,但是不会发送电子邮件。
我已经检查了垃圾邮件文件夹以及所有内容,但是它不起作用。我想知道我的代码是否存在问题,即5.6更能容忍5.6而不是7.2,或者我的代码中是否存在不再受支持的功能?
如果您有时间看看到底发生了什么,请您看看我的代码吗?
<?php
if(!isset($_POST['submit']))
{
//This page should not be accessed directly. Need to submit the form.
echo "error; You need to submit the form!";
}
$fname = $_POST['fname'];
$midname = $_POST['midname'];
$lname = $_POST['lname'];
$age = $_POST['age'];
$cust_email = $_POST['cust_email'];
$phone = $_POST['phone'];
$priorstudent = $_POST['priorstudent'];
$priorstudentdate = $_POST['priorstudentdate'];
$gunexperience = $_POST['gunexperience'];
$experiencedetails = $_POST['experiencedetails'];
$trainingpackage = $_POST['trainingpackage'];
$customergun = $_POST['customergun'];
$guntype = $_POST['guntype'];
$referred_by = $_POST['referred_by'];
$referred_details = $_POST['referred_details'];
//Validate first
if(empty($fname)||empty($lname)||empty($cust_email))
{
echo "Full name and email are mandatory!";
exit;
}
if(IsInjected($visitor_email))
{
echo "Bad email value!";
exit;
}
$email_subject = "New Form submission";
$email_body = "First Name: $fname \n Middle Name: $midname \n Last Name: $lname \n Age: $age \n\n Email: $cust_email \n Phone: $phone \n Prior Student: $priorstudent - $priorstudentdate \n Experience: $gunexperience \n $experiencedetails \n\n Training: $trainingpackage \n Firearm: $customergun - $guntype \n\n Referred: $referred_by - $referred_details \n".
$headers = "Reply-To: $cust_email \r\n";
// if the url field is empty
if(isset($_POST['url']) && $_POST['url'] == ''){
//Send the email!
mail("ken@sflguntraining.com", $email_subject, $email_body, $visitor_email);
//done. redirect to thank-you page.
header('Location: thank-you.html');
}
// Function to validate against any email injection attempts
function IsInjected($str)
{
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
// if url field is not empty
?>
<h1>Thanks!</h1>
We'll get back to you as soon as possible.
很抱歉粘贴整个内容,我知道我只应该指出问题的可能原因,但问题是我没有任何线索...众所周知,有关空白url的部分有点像自动填充机器人的把戏。表单本身声明将其保留为空白,但是自动填充漫游器应在其中填充一个URL,这将导致显示伪造的感谢消息,而不是在发送电子邮件后引用实际的感谢页面。当我正确填写它时,它会正确地指向真实的“谢谢”页面,如果在“ URL”框中输入任何内容,它将显示虚假的“谢谢”消息。一切似乎正常,但实际上没有发送电子邮件。