pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chadwick Rolfs <cmr@shell.gis.net>
To: pgsql-php@postgresql.org
Subject: Re: Problem involving checkbox and Postgresql
Date: Fri, 21 Jun 2002 09:44:24 -0400 (EDT)
Message-ID: <Pine.SOL.3.96.1020621093804.25405B-100000@shell.gis.net> (raw)
In-Reply-To: <200206171403.25668.wokan@cox.net>

On Mon, 17 Jun 2002, Digital Wokan wrote:

> All of which brings up the fact that you should never just trust all the 
> values being submitted to a page.  That's how SQL insertion attacks succeed.
> 
> On Thursday 20 June 2002 13:22, Scott Marlowe wrote:
> > You have to process the values yourself to make sure it's right.
> >
> > Just do something like this:
> >
> > if ($driving_required == "1") $driving_required = 't';
> > else $driving_required = 'f';
> >
> > Then use it in your update / insert statement as usual.
> >
> > On 20 Jun 2002, Jeff Self wrote:
> > > That only works if I leave the checkboxes checked. If I remove the
> > > check, I get the following error:
> > >
> > > Warning:  pg_exec() query failed:  ERROR:  Bad boolean external
> > > representation ''
> > >  in /var/www/nngov/admin/jobpostresults.php on line 66
> > >
> > > On Thu, 2002-06-20 at 13:39, Surojit Niyogi wrote:
> > > > Hi Jeff,
> > > >
> > > > Set the value parameter in the input tag
> > > >
> > > > <input type="checkbox"
> > > > name="driving_required" CHECKED value='1'>
> > > >
> > > > That should work I believe.
> > > >
> > > > -Surojit

I just looked it up, and the value attribute is optional EXCEPT when the
type is either radio or checkbox.  Therefore you must specify some sort of
value; it could even be 'on' if you want ;)
See here:

http://www.w3.org/TR/html4/interact/forms.html#h-17.4

Either way, as stated above, all values should be checked in a production
state, but to manipulate your $_POST or $_GET arrays and turn them into
sql query strings, it is sometimes necessary to individually search and
replace values that do not work with sql.  In other words, html form
values were not meant to be sent to database back ends in the form of sql,
hence we have php to change them for us :)  Hooray for that!

-Chadwick




view thread (11+ messages)

Message-ID: <Pine.SOL.3.96.1020621093804.25405B-100000@shell.gis.net>
Permalink:  ../Pine.SOL.3.96.1020621093804.25405B-100000@shell.gis.net/
Also on:    postgresql.org/message-id/Pine.SOL.3.96.1020621093804.25405B-100000@shell.gis.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: cmr@shell.gis.net
  Subject: Re: Problem involving checkbox and Postgresql
  In-Reply-To: <Pine.SOL.3.96.1020621093804.25405B-100000@shell.gis.net>
  References: <200206171403.25668.wokan@cox.net> <Pine.SOL.3.96.1020621093804.25405B-100000@shell.gis.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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