好的,所以我将一个 html 5 表单发送到一个带有一些隐藏字段的 php 脚本。一个隐藏的领域正在工作,但另一个没有。有人可以帮我清理一下吗?
这是表格:
<form action="mail_action.php" method="post">
<!--Hidden information data-->
<input type="hidden" name="email_address" value="example@googlemail.com" />
<input type="hidden" name="email_subject" value="Hello World" />
<!--The form-->
<input name="form_data[]">
<input name="form_data[]">
<input name="form_data[]">
<input type="submit">
</form>
这是脚本:
<?php
//Grabbing hidden field data.
$email = $_POST["email_address"];
$subject = $_POST["email_subject"];
$headers = 'From: no-reply@example.co.uk' . "\r\n" .
'Reply-To: no-reply@example.co.uk' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
foreach($_POST['form_data'] as $item)
{
//Asigning the message fields to $message variable.
$message .= $item;
//The spaces inbetweeen
$message .= "\r\n";
}
if(mail ($email, $subject, $message, $headers)){
echo "Your Message was sucessfully emailed to: ".$email;
} else {
echo "Opps, Didn't send.";
}
?>
email_address 隐藏字段有效,但主题无效,谢谢。