我使用了一个 php 复选框,我想检索标记的值.
我的复选框代码:
I use a php checkbox and I want to retrieve marked values.
My checkbox code :
<label for="cours">Je suis intéressé par un ou plusieurs cours :</label><br><br>
<input type="checkbox" name="cours" value="individuel">Individuel<br>
<input type="checkbox" name="cours" value="semiprive">Semi-privé<br>
<input type="checkbox" name="cours" value="minigroupe">Mini-groupe<br>
<input type="checkbox" name="cours" value="intensif">Intensif<br>
<input type="checkbox" name="cours" value="entreprise">Entreprises<br>
<input type="checkbox" name="cours" value="distance">A distance<br>
<input type="checkbox" name="cours" value="telephone">Par téléphone<br>
<input type="checkbox" name="cours" value="coaching">Coaching<br>
<input type="checkbox" name="cours" value="soutien">Soutien scolaire<br>
<input type="checkbox" name="cours" value="diplome">Diplômes officiels<br>
php:
<?php
if(isset($_POST['envoyer']))
{
if(get_magic_quotes_gpc())
{
$cours = stripslashes(trim($_POST['cours']));
}
}
?>
我想把它放在变量 msg 中:
I want to put it in the variable msg :
$msg = 'Cours : '.$cours."
";
发送消息会抛出php电子邮件功能.
但是当我这样做时,只会收到第一个选中的选项...
谢谢你的帮助.
迈克尔
and sending the message throw the php email function.
But when I do that like this a receive just the first checked choice...
Thank you for your help.
Michaël
你必须将 name 属性更改为 cours[] ,然后 php 会将其视为一个数组.
You have to change the name attribute to cours[] and then php will treat it as an array.
阅读 http://docs.php.net/faq.html
这篇关于从复选框中检索值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
以编程方式将可下载文件添加到 Woocommerce 产品Add programmatically a downloadable file to Woocommerce products(以编程方式将可下载文件添加到 Woocommerce 产品)
获取今天 Woocommerce 中每种产品的总订单数Get today#39;s total orders count for each product in Woocommerce(获取今天 Woocommerce 中每种产品的总订单数)
在 WooCommerce 和电话字段验证问题中添加自定义注Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和电话字段验证问题中添加自定义注册字段
在 Woocommerce 简单产品中添加一个将更改价格的选Add a select field that will change price in Woocommerce simple products(在 Woocommerce 简单产品中添加一个将更改价格的选择字段)
在 WooCommerce 3 中将自定义列添加到管理产品列表Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中将自定义列添加到管理产品列表)
自定义结帐“下订单"按钮输出htmlCustomizing checkout quot;Place Orderquot; button output html(自定义结帐“下订单按钮输出html)