我正在搜索从表单创建数组并将其传输到另一个页面的方法: 这是我的实际代码:
<?php
$nba = $_GET["nbadultes"]; // recup number of passangers
$adu = array();
for ($i=1;$i<=$nba;$i++)
{
echo '<h3>Passager '.$i.'</h3>
<label>CIVILITÉ</label>
<select class="full-width" name="Civilite">
<option value="Mr" selected >Mr.</option>
<option value="Mrs" >Mrs.</option>
</select>
<label>FIRSTNAME *</label>
<input type="text" name="FIRSTNAME"/>
<label>LASTNAME *</label>
<input type="text" name="LASTNAME"/> ';
$adu[$i][civilite] = $_POST['civilite'];
$adu[$i][FIRSTNAME] = $_POST['FIRSTNAME'];
$adu[$i][LASTNAME] = $_POST['LASTNAME'];
}
$_SESSION['liste_adultes'] =$adu;
?>
这个代码在下一页读取数组:
<?php
if (isset($_SESSION['liste_adultes']))
print_r ($liste_adultes);
?>
但我不知道为什么数组是空的:
Array
(
[1] => Array
(
[Civilite] =>
[FIRSTNAME ] =>
[LASTNAME] =>
)
[2] => Array
(
[Civilite] =>
[FIRSTNAME ] =>
[LASTNAME] =>
)
)