Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP表单发送空白电子邮件_Php_Email - Fatal编程技术网

PHP表单发送空白电子邮件

PHP表单发送空白电子邮件,php,email,Php,Email,我对PHP没有太多经验——我使用了一个表单生成器来创建这个表单。问题是表单发送了数百封空白电子邮件。谁能帮我修一下吗?以下是PHP代码: <?php $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/")); mail("blah@blah.com","MESSAGE: website"," Someone has submitted a mes

我对PHP没有太多经验——我使用了一个表单生成器来创建这个表单。问题是表单发送了数百封空白电子邮件。谁能帮我修一下吗?以下是PHP代码:

 <?php

$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

mail("blah@blah.com","MESSAGE: website","

Someone has submitted a message from your website!  Huzzah!

--------------------------------------------------------------------------------

CONTACT INFO:
" . $_POST['field_1'] . "
" . $_POST['field_2'] . " 

MESSAGE:
" . $_POST['field_3'] . " 

--------------------------------------------------------------------------------

Also you're a stud.

");

header("Refresh: 0;url=http://www.blah.com/thanks.html");

?>

如果您只需确保某人确实
发布了
数据(即实际使用了表单),您就可以:

<?php
    $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

        if (!$_POST['field_1'] || !$_POST['field_2'] || !$_POST['field_3']) {
            header("Location: $where_form_is");
            exit;
        }

    mail("blah@blah.com","MESSAGE: website","Someone has submitted a message from your website!  Huzzah!
    CONTACT INFO:
    " . $_POST['field_1'] . "
    " . $_POST['field_2'] . " 

    MESSAGE:
    " . $_POST['field_3'] . " 
    Also you're a stud.");

    header("Refresh: 0;url=http://www.blah.com/thanks.html");
    exit;
?>

确保您的html表单方法是POST,或者在php上使用$\u GET或$\u REQUEST,该$\u REQUEST的值与($\u POST |$\u GET)的值相同