我没有很多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");
?>
答案 0 :(得分:0)
如果您只是确保某人实际POST
通过了数据(即实际使用过该表单),那么您将会很高兴:
<?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;
?>