ユーザーが選択ボックスを介してフォームに他のユーザーを追加できるようにしようとしています。したがって、ユーザーはドロップダウン選択から別のユーザーを選択し、[ユーザーの追加] を押すと、それらのユーザーが配列に追加されます。ユーザーは別のユーザーを選択でき、その 2 番目のユーザーをこの配列に追加する必要があります。現在、ユーザーが追加されるたびに、元のユーザーは消えます。非表示の入力を使用してみましたが、うまくいきません。
formprocessing.php について
//this generates a list of users. The code to actually generate the users is omitted
<center><h3>Invite Friends</h3></center><br>
<form method="post">
<tr><td>Friends:</td><td><select name ="friend"><Option value="">Friends<? echo $selection; ?></Select></td>
<input type="hidden" name="hiddenFriends" value="<? echo $friends; ?>"/>
<td><input type="submit" name="submitFriend" value="Add Friend"/>
</form>
form.php について
//i'm trying to create an array of users which are added. When completed, they'll be added to the db
<?
if(isset($_POST['submitFriend'])){
if(count($_POST['hiddenFriends']) > 0){
$friend = $_POST['friend'];
array_push($friends,$_POST['friend']);
}
else{
$friends = array('');
array_push($friends,$_POST['friend']);
}
}
?><input type="hidden" name="hiddenFriends" value="<? echo $friends; ?>"/><?
print_r($friends);
?>