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.

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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.