繁体   English   中英

联系表格发送给我空的电子邮件

[英]Contact Form Sends me Empty emails

我有这个联系表格,运作良好。 如果有人给我发了一封电子邮件,我就知道了 但无论出于何种原因,我都会收到空的电子邮件发送给我。 由于没有人可以访问该页面,我确定不是有人向我发送空的电子邮件。 我不知道问题是什么。 有帮助吗?

   <form method="post" id="contactform" name="contactform" action="comment.php" id="ContactForm" name="ContactForm" method="post">

    <fieldset>

    <label>Email *</label>
    <input class="text" type="text" name="email">
    <label>Name *</label>
    <input class="text" type="text" name="name" />

    </fieldset>

    <input class="submit-button" type="submit" name="submit" id="submit" value="Send" />
</form>

and my contact.php

    <?php


    $email.= "<b>Email     : </b>".trim($_POST['company'])."<br/>";
    $email.= "<b>Name      : </b>".trim($_POST['name'])."<br/>";



    //Replace YourEmailAddress@Yourdomain.com with yours, eg:contactus@mywebsite.com
        //Both on the next line and on the mail function below.
    $headers = "From: email@email.com\r\n";
    $headers .= "Content-Type: text/html";
    mail(
            "Your Name<myname>", 
            "Header", 
            $email,
            $headers
    );
        header("www.google.com");
?>

我的php表单中的“标题”部分是在发送表单后将用户重定向到页面。

提前致谢。

你可能正在接受机器人的访问。 即使没有POST数据,您的脚本也会始终触发电子邮件。

在您的联系人脚本中,作为保护的基本衡量标准,添加类似的内容

if ($_POST["submit"] != "Send") 
 die();

根据需要添加进一步验证(如评论中所指出)。

可能是因为您似乎没有验证表单输入,因此可以将其提交为空白。

有时我会对网站执行此操作(测试验证,最后发送空白电子邮件),但我通常会在稍后添加消息“验证您的输入!”。

对不起,如果你确实在做验证,但这是我的直觉,因为我看到很多人甚至无法验证是否存在所需的输入,更不用说完整性了。

公司不存在于您的表单中,但您尝试解析它。

也许2个表格名称声明不是那么好,但它不是你的答案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM