Reckoner Posted May 24, 2012 Share Posted May 24, 2012 Hello, so I am getting closer to finally completing my form. However, I need it so that the US states in my form are able to retrieve the VALUE section of it. http://bayardclient.com/fastaff/shor...layout_new.php For example, in my html code, I have each set up as follows: <input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="[states]" id="Arkansas" value="AR"/> Arkansas <input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="[states]" id="California" value="CA"/> California and in the PHP, I have it set up like: <?php session_start(); { if(isset($_POST['Submit'])) $states = $_POST['states']; but it doesn't seem to be working. That is how i have set up the other fields on my form, with the $name = $_POST['name']; Can some one please possibly steer me in the right direction?? Would be very appreciative. Quote Link to comment https://forums.phpfreaks.com/topic/263084-how-to-post-an-array-of-checkbox-values-to-web-form-in-php/ Share on other sites More sharing options...
smoseley Posted May 25, 2012 Share Posted May 25, 2012 name="states[]" Quote Link to comment https://forums.phpfreaks.com/topic/263084-how-to-post-an-array-of-checkbox-values-to-web-form-in-php/#findComment-1348499 Share on other sites More sharing options...
Reckoner Posted May 25, 2012 Author Share Posted May 25, 2012 hmmm thanks for the reply. That still didn't work. Would just display results as "Array" After hours of scouring the net, I found a method to get it to work by using: $states .= implode(', ', $_POST['states']); just thought to post here in case some sorry soul has the same issue I did. In general, what is the best way to learn this stuff? PHP is somewhat rough for me since there are so many unforseen things I have no idea in how to do. Quote Link to comment https://forums.phpfreaks.com/topic/263084-how-to-post-an-array-of-checkbox-values-to-web-form-in-php/#findComment-1348600 Share on other sites More sharing options...
smoseley Posted May 26, 2012 Share Posted May 26, 2012 If it says "Array" when you echo it, then it worked... If you want to see the contents, try: print_r($_POST['states']); Imploding is one way of working with an array... suggest you read up on others. Quote Link to comment https://forums.phpfreaks.com/topic/263084-how-to-post-an-array-of-checkbox-values-to-web-form-in-php/#findComment-1348771 Share on other sites More sharing options...
alvin567 Posted June 3, 2012 Share Posted June 3, 2012 there is also another way which is to trigger_error? Quote Link to comment https://forums.phpfreaks.com/topic/263084-how-to-post-an-array-of-checkbox-values-to-web-form-in-php/#findComment-1350765 Share on other sites More sharing options...
smoseley Posted June 3, 2012 Share Posted June 3, 2012 there is also another way which is to trigger_error? What are you talking about??? Quote Link to comment https://forums.phpfreaks.com/topic/263084-how-to-post-an-array-of-checkbox-values-to-web-form-in-php/#findComment-1350836 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.