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? Quote Link to comment 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 ; } Quote Link to comment Share on other sites More sharing options...
xtopolis Posted May 6, 2009 Share Posted May 6, 2009 Are you saying it works now then? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.