pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Question about checkboxes in forms
2+ messages / 2 participants
[nested] [flat]

* Question about checkboxes in forms
@ 2004-06-03 00:44  Lynna Landstreet <lynna@gallery44.org>
  0 siblings, 1 reply; 2+ messages in thread

From: Lynna Landstreet @ 2004-06-03 00:44 UTC (permalink / raw)
  To: pgsql-php

Hi folks,

I'm running into a bit of trouble processing a form I set up. When I extract
the information from $_POST after submitting the form, everything comes
through fine except for the one form field that uses checkboxes - only the
last value checked comes through in that one.

In my past experience, when using checkboxes in formmail scripts and the
like, what comes through is a list of the values checked, separated by
commas. Does it still work that way when capturing the form data with PHP?
If so, could the commas be throwing it off? I was expecting the contents of
$_POST[keywords] to be a string of keyword IDs separate by commas, which I
could then explode into an array, but instead I only get the last value
checked, as though each box checked replaced the previous one.

The keyword checkboxes are generated from the database, but from looking at
the source on the resulting web page the HTML seems to be fine. Each
checkbox looks something like this:

<input type="checkbox" name="keywords" value="152">

They all have the name "keywords", but that's the norm for checkboxes and
radio buttons, isn't it? Usually it just groups all the values for each
named group of checkboxes into one string, but not this time, apparently.

Any ideas?


Lynna

-- 
Resource Centre Database Coordinator
Gallery 44
www.gallery44.org




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Question about checkboxes in forms
@ 2004-06-03 00:56  Chris <chris@interspire.com>
  parent: Lynna Landstreet <lynna@gallery44.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Chris @ 2004-06-03 00:56 UTC (permalink / raw)
  To: 'Lynna Landstreet' <lynna@gallery44.org>; pgsql-php

Hi Lynna,

Try this instead

<input type="checkbox" name="keywords[]" value="152">

Then when you get $_POST, it'll be an array....

That should fix it up =)

Regards,
 
Chris Smith

Suite 30, 45-51 Huntley St, Alexandria, NSW 2015 Australia

Ph: +61 2 9517 2505
Fx: +61 2 9517 1915 

email: info@interspire.com
web: www.interspire.com 


-----Original Message-----
From: pgsql-php-owner@postgresql.org
[mailto:pgsql-php-owner@postgresql.org] On Behalf Of Lynna Landstreet
Sent: Thursday, June 03, 2004 10:44 AM
To: pgsql-php@postgresql.org
Subject: [PHP] Question about checkboxes in forms


Hi folks,

I'm running into a bit of trouble processing a form I set up. When I
extract the information from $_POST after submitting the form,
everything comes through fine except for the one form field that uses
checkboxes - only the last value checked comes through in that one.

In my past experience, when using checkboxes in formmail scripts and the
like, what comes through is a list of the values checked, separated by
commas. Does it still work that way when capturing the form data with
PHP? If so, could the commas be throwing it off? I was expecting the
contents of $_POST[keywords] to be a string of keyword IDs separate by
commas, which I could then explode into an array, but instead I only get
the last value checked, as though each box checked replaced the previous
one.

The keyword checkboxes are generated from the database, but from looking
at the source on the resulting web page the HTML seems to be fine. Each
checkbox looks something like this:

<input type="checkbox" name="keywords" value="152">

They all have the name "keywords", but that's the norm for checkboxes
and radio buttons, isn't it? Usually it just groups all the values for
each named group of checkboxes into one string, but not this time,
apparently.

Any ideas?


Lynna

-- 
Resource Centre Database Coordinator
Gallery 44
www.gallery44.org


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2004-06-03 00:56 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-06-03 00:44 Question about checkboxes in forms Lynna Landstreet <lynna@gallery44.org>
2004-06-03 00:56 ` Chris <chris@interspire.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox