Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.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 如何从html5表单中添加复选框结果?_Php_Html_Forms - Fatal编程技术网

Php 如何从html5表单中添加复选框结果?

Php 如何从html5表单中添加复选框结果?,php,html,forms,Php,Html,Forms,我在html5文档中使用了一个超级简单的表单。我目前不需要验证器或任何花哨的东西,但我很难找到如何在电子邮件中包含复选框的结果 html中的表单代码为: <div id="subscribe_form"> <form action="mail.php" method="post" target="_blank"> <input type="text" name="name" placeholder="Name" /><br> <inpu

我在html5文档中使用了一个超级简单的表单。我目前不需要验证器或任何花哨的东西,但我很难找到如何在电子邮件中包含复选框的结果

html中的表单代码为:

<div id="subscribe_form">
<form action="mail.php" method="post" target="_blank">

 <input type="text" name="name" placeholder="Name" /><br>

<input type="email" name="email" placeholder="Email" /><br>

<textarea name="message" rows="6" cols="30" placeholder="Mailing Address" ></textarea><br />


<input type="checkbox" id="hascurrent" value="yes" />
<label for="hascurrent">I've already received the current issue of Critters &amp; Gods.</label>

<br>
<button type="submit" value="Send">Subscribe</button>

</form>




我已经收到了最新一期的《小动物》杂志;诸神。
订阅

整个mail.php表单包括:

<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="Subscriber: $name Email: $email Address: $message Has current issue: $hascurrent";
$recipient = "subscriptions@crittersandgods.com";
$subject = "New Subscription";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "<div id='form_echo'> Thank you, $name, for subscribing to Critters & Gods. Your subscription is completely free and will not expire. If at any time you wish to unsubscribe from Critters & Gods, visit the about page for information. </div>";
?>

名称
属性添加到复选框
输入

<input type="checkbox" id="hascurrent" name="hasCurrent" value="yes" />
如果选中,
$hasCurrent
的值将为
yes
,否则为空

$hasCurrent = $_POST['hasCurrent'];