さて、隠しフィールドを持つphpスクリプトにhtml 5フォームを送信しています。1 つの非表示フィールドは機能していますが、もう 1 つのフィールドは機能していません。誰かが私が物事を片付けるのを手伝ってくれますか?
フォームは次のとおりです。
<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 非表示フィールドは機能しますが、件名は機能しません。今後ともよろしくお願いいたします。