在PHP中将数组从一个页面传递到另一个页面

时间:2021-07-09 17:07:03

I have a register form (for events) in which the number of fields input are not same. It depends upon the events. Different events limit different numbers of members for registration. So, in my events TABLE I've a row members which store the number of members.

我有一个寄存器表单(用于事件),其中输入的字段数不相同。这取决于事件。不同的事件限制了不同数量的成员进行注册。所以,在我的事件表中,我有一个存储成员数的行成员。

So,finally my registration form goes like this:

所以,最后我的注册表格如下:

if ($row['members']>1){
    echo "Hello ".$sess_name.", you can add ".($row['members']-1)." more members to register for ".$row['name']."<br>";
    echo "On successful registration of the event, all the team members will receive an email on their registered email ids<br>";
    $mem=array();?>
    <form action="" method="post">
    <?php for ($i=1;$i<$row['members'];$i++){
        echo '<label>Insert ID of Member '.$i.' :</label>';
        echo '<input type="text" id="id" size="20" name="'.$mem[].'"><br>';
    }
    echo '<button type="submit" id="submit" value="Register" name="register1">Register</button>';?>
    </form>

I'm storing the ID that are being input in an array($mem) But I don't know how to pass it ($mem) in another page to store it in MySQL table.

我正在存储在数组中输入的ID($ mem)但是我不知道如何在另一个页面中传递它($ mem)以将其存储在MySQL表中。

1 个解决方案

#1


0  

Add an hidden input field

添加隐藏的输入字段

<form action="" method="post">
<?php for ($i=1;$i<$row['members'];$i++){
    echo '<label>ID of Member '.$i.' :</label>';
    echo '<input type="text" id="email" size="20" name="'.$mem[].'"><br>';
    echo '<input type="hidden" id="userID" name="userID[]" value='.$i.'>';
}
echo '<button type="submit" id="submit" value="Register" name="register1">Register</button>';?>
</form>

#1


0  

Add an hidden input field

添加隐藏的输入字段

<form action="" method="post">
<?php for ($i=1;$i<$row['members'];$i++){
    echo '<label>ID of Member '.$i.' :</label>';
    echo '<input type="text" id="email" size="20" name="'.$mem[].'"><br>';
    echo '<input type="hidden" id="userID" name="userID[]" value='.$i.'>';
}
echo '<button type="submit" id="submit" value="Register" name="register1">Register</button>';?>
</form>