xtiancjs Posted May 6, 2009 Share Posted May 6, 2009 Hi , I have a form which adds names to a list 3 at a time. I have it adding the first lot of 3 no problem, when I try and resubmit the form the original 3 names are replaced by the later 3. I am trying to have them add to the original so a larger list is formed. My HTML: <input id="firstname" type="text" name="firstname[]" size="20"><br> <input id="firstname" type="text" name="firstname[]" size="20"><br> <input id="firstname" type="text" name="firstname[]" size="20"> My PHP code: foreach($_POST['firsname'] as $value) { $_SESSION['firstname'] = $value ; } Any ideas? Link to comment https://forums.phpfreaks.com/topic/157030-solved-adding-to-session-array-multiple-times/ Share on other sites More sharing options...
xtiancjs Posted May 6, 2009 Author Share Posted May 6, 2009 Ouch ! my bad - forgot to add "[]" to the $session variable. so it should read: foreach($_POST['firsname'] as $value) { $_SESSION['firstname'][] = $value ; } Link to comment https://forums.phpfreaks.com/topic/157030-solved-adding-to-session-array-multiple-times/#findComment-827197 Share on other sites More sharing options...
xtopolis Posted May 6, 2009 Share Posted May 6, 2009 Are you saying it works now then? Link to comment https://forums.phpfreaks.com/topic/157030-solved-adding-to-session-array-multiple-times/#findComment-827198 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.