hassank1 Posted May 12, 2008 Share Posted May 12, 2008 Hi I've a form that contains checkboxes (their number is dynamic) .. these checkboxes contains different value .. I want when processing the form (POST) .. to get the values of the checked checkboxes only and save them in an array .. how can I do that ? thx Link to comment https://forums.phpfreaks.com/topic/105272-posting-checkboxes/ Share on other sites More sharing options...
pocobueno1388 Posted May 12, 2008 Share Posted May 12, 2008 Can you show us the HTML output of your checkboxes? Basically you want to name all your checkboxes something like "check[]". Then when the form is submitted all the values will already be stored in the array called $_POST['check']. Link to comment https://forums.phpfreaks.com/topic/105272-posting-checkboxes/#findComment-539046 Share on other sites More sharing options...
hassank1 Posted May 12, 2008 Author Share Posted May 12, 2008 echo "<input name=\"$message[MID]\" type=\"checkbox\" id=\"$message[MID]\" value=\"$message[MID]\">"; so I think I must change it to : echo "<input name=\"check[]\" type=\"checkbox\" id=\"check[]\" value=\"$message[MID]\">"; ?? however , the check[] array will only contain the checked values right ? Link to comment https://forums.phpfreaks.com/topic/105272-posting-checkboxes/#findComment-539056 Share on other sites More sharing options...
pocobueno1388 Posted May 12, 2008 Share Posted May 12, 2008 however , the check[] array will only contain the checked values right ? Yes. Try that out and see if the array comes out how you want it. Link to comment https://forums.phpfreaks.com/topic/105272-posting-checkboxes/#findComment-539089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.