Jump to content

How to post an array of checkbox values to web form in PHP?


Reckoner

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.