我在我网站的页脚部分有一个表单,它通过电子邮件向我发送基本用户输入和当前页面网址 . 这是它的布局

<form action="" id="myform" method="post">
    <input name="name" type="text" class="transparent-white-border-input" placeholder="Your Name">
    <input name="email" type="text" class="transparent-white-border-input" placeholder="Email Address">
    <textarea name="enquiry" class="transparent-white-border-input" rows="5" placeholder="Enquiry or Project Details...."></textarea>
    <input name="from_page" type="hidden" value="<?=$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI]?>">
    <div class="send-btn">Send</div>
</form>

以下是我的ajax提交和javascript验证

<script>
$('.send-btn').click(function(){
    if(validateForm()){
        $.ajax({
            url: "/ajax-request.php?function=footer_contact_form",
            type: "post",
            data: $("#myform").serialize(),
            success: function() {
                $(".emocean-contact-form .section-container").html('<h1 style="color: #fff; text-align:center;">Thank you for contacting us, we will get back to you shortly.</h1>');
            }
        });
    }
    else{
        alert("Please fill in all fields in blue.");
    }
})
function validateForm(){
    a=document.forms["myform"]["name"];
    a_regex=/\S/;
    d=document.forms["myform"]["email"];
    d_regex=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; //stackoverflow standard
    e=document.forms["myform"]["enquiry"];  
    e_regex= /\S/;

    valid = true;
    $("#myform input").css("backgroundColor", "");
    $("#myform textarea").css("backgroundColor", "");

    function check (origin, regex){
        if (!regex.test(origin.value)){
            origin.style.backgroundColor="blue";
            valid = false;          
        }   
    }

    check(a, a_regex);
    check(d, d_regex);
    check(e, e_regex);

    return valid;
}       
</script>

这就是问题所在 . 我测试了不同的设备和不同的浏览器,但一切正常 . 但是当它上线时,它会像测试一样通过电子邮件向我发送正确的信息,但有时它会向我发送一封包含所有帖子数据空白的电子邮件,甚至$ _post [“from_page”]也是空白 . 不知道这是怎么回事 . 我试图在浏览器控制台中提交此表单以绕过验证,而大多数字段都是空白的$ _post [“from_page”]仍然有 Value .

此外,它看起来不像垃圾邮件机器人的东西,因为空白的电子邮件现在经常出现,而且它们都是随机的 . 如前所述,有些电子邮件不是空白的 . 任何人都知道问题可能是什么?

This post可能相关也可能不相关 .