Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 898C3475F5A for ; Thu, 20 Jun 2002 22:52:01 -0400 (EDT) Received: from fed1mtao04.cox.net (fed1mtao04.cox.net [68.6.19.241]) by postgresql.org (Postfix) with ESMTP id D30DE475B72 for ; Thu, 20 Jun 2002 22:33:42 -0400 (EDT) Received: from monster.creatures ([68.2.213.242]) by fed1mtao04.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20020621023346.NCAJ26656.fed1mtao04.cox.net@monster.creatures> for ; Thu, 20 Jun 2002 22:33:46 -0400 Content-Type: text/plain; charset="iso-8859-1" From: Digital Wokan To: pgsql-php@postgresql.org Subject: Re: Problem involving checkbox and Postgresql Date: Mon, 17 Jun 2002 14:03:25 -0700 User-Agent: KMail/1.4.1 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200206171403.25668.wokan@cox.net> X-Archive-Number: 200206/42 X-Sequence-Number: 1295 All of which brings up the fact that you should never just trust all the=20 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 =3D=3D "1") $driving_required =3D 't'; > else $driving_required =3D '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 > > > > > > > > name=3D"driving_required" CHECKED value=3D'1'> > > > > > > That should work I believe. > > > > > > -Surojit > > > > > > Jeff Self wrote: > > > >I've got a table with a field called driving_required with a boolean > > > >type and default 'true'. I've built a web page which contains the > > > >following lines for displaying a checkbox: > > > > > > > >Driver's License Required? > > > > > > >name=3D"driving_required" CHECKED> > > > > > > > >After the form is submitted, it calls a php file called > > > >jobpostresults.php which enters the data from the form into the > > > > database and displays the results on the page. > > > > > > > >Here's the section that enters the form data into the database: > > > > > > > >// Add Job Description Details > > > >$jddquery =3D "INSERT INTO job_description_details (description_id, > > > >effective_date, driving_required, submitted_on, submitted_by, > > > >sm_description, responsibilities, behaviors, skills, experience, > > > >requirements) VALUES > > > >('$description_id','$effective_date','$driving_required',now(),'$sub= mi > > > >tted_by','$sm_description','$responsibilities','$behaviors','$skills= ', > > > >'$experience','$requirements')"; > > > > > > > >$jddresult =3D pg_exec($conn, $jddquery); > > > >if (!$jddresult) > > > > exit; > > > > > > > >When I input the data and click on submit I get the following error > > > >message: > > > > > > > >Warning: pg_exec() query failed: ERROR: Bad boolean external > > > >representation 'on' > > > > in /var/www/nngov/admin/jobpostresults.php on line 46 > > > > > > > >It looks like the html form is producing 'on' for the value of > > > >driving_required. How do I get this changed to 'true' in PostgreSQL? > > > > > > ---------------------------(end of > > > broadcast)--------------------------- TIP 3: if posting/reading throu= gh > > > Usenet, please send an appropriate subscribe-nomail command to > > > majordomo@postgresql.org so that your message can get through to the > > > mailing list cleanly