【发布时间】:2012-01-15 01:54:57
【问题描述】:
看起来 send.php 正在被访问并发送空白电子邮件。需要使 send.php 不发送电子邮件,除非在表单上使用提交按钮。有人告诉我 'isset $_post' 会帮助我,只是不清楚如何执行它。
这里是 send.php 代码:
<?php
$recipient = 'test@test.com';
$email = $_REQUEST['Email'];
$subject = 'Contact Form Submission';
$content = "The following has been submitted on your website \n\n";
$redirect = 'thankyoupage.html';
$user = $_REQUEST['Email'];
$usersubject = "Subject";
$userheaders = "From: test@test.com\n";
$usermessage = "Blah blah blah";
mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders);
foreach($_POST as $k=>$v)
{
$content .= "$k: $v\n\n";
}
mail_it(stripslashes($content), $subject, $email, $recipient);
if (isset($_POST['redirect']))
{
header("Location:".$_POST['redirect']);
}
else
{
header("Location: $redirect");
}
function mail_it($content, $subject, $email, $recipient)
{
$headers .= "From: ".$email."\n";
$headers .= "Reply-To: ".$email."\n";
if ($bcc) $headers .= "Bcc: ".$bcc."\n";
$headers .= "X-Priority: 0\n";
$headers .= "X-Mailer: bjm Formmail \n";
$message = $content."\n\n";
if( !mail($recipient, $subject, $message, $headers))
{
echo "Sorry - an error occured trying to send the mail";
}
}
?>
【问题讨论】:
-
你是怎么调用 send.php 的?
-