pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Problem involving checkbox and Postgresql
11+ messages / 8 participants
[nested] [flat]

* Re: Problem involving checkbox and Postgresql
@ 2002-06-17 21:03  Digital Wokan <wokan@cox.net>
  parent: Scott Marlowe <scott.marlowe@ihs.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Digital Wokan @ 2002-06-17 21:03 UTC (permalink / raw)
  To: pgsql-php

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
> > >
> > > 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:
> > > >
> > > ><tr><td width="25%" class="form">Driver's License Required?</td>
> > > >    <td width="75%" class="form"><input type="checkbox"
> > > >name="driving_required" CHECKED></td></tr>
> > > >
> > > >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 = "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(),'$submi
> > > >tted_by','$sm_description','$responsibilities','$behaviors','$skills',
> > > >'$experience','$requirements')";
> > > >
> > > >$jddresult = 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 through
> > > Usenet, please send an appropriate subscribe-nomail command to
> > > majordomo@postgresql.org so that your message can get through to the
> > > mailing list cleanly




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

* Re: Problem involving checkbox and Postgresql
@ 2002-06-20 07:57  David C. Brown <dbrown@centennialwines.com>
  parent: Jeff Self <jself@nngov.com>
  4 siblings, 0 replies; 11+ messages in thread

From: David C. Brown @ 2002-06-20 07:57 UTC (permalink / raw)
  To: Jeff Self <jself@nngov.com>; +Cc: Surojit Niyogi <surojit@bungeecode.com>; pgsql-php

It returns "on" as true.  Just test the value of $driving_required and 
assign the proper boolen value for postgresql..

If ($driving_required=='on') {
     $driving_required=TRUE;
} else {
     $driving_required=FALSE;
}

Dave
                       

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
>>
>>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:
>>>
>>><tr><td width="25%" class="form">Driver's License Required?</td>
>>>   <td width="75%" class="form"><input type="checkbox"
>>>name="driving_required" CHECKED></td></tr>
>>>
>>>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 = "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(),'$submitted_by','$sm_description','$responsibilities','$behaviors','$skills','$experience','$requirements')";
>>>
>>>$jddresult = 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 through Usenet, please send an appropriate
>>subscribe-nomail command to majordomo@postgresql.org so that your
>>message can get through to the mailing list cleanly
>>    
>>





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

* Problem involving checkbox and Postgresql
@ 2002-06-20 16:36  Jeff Self <jself@nngov.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Jeff Self @ 2002-06-20 16:36 UTC (permalink / raw)
  To: pgsql-php

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:

<tr><td width="25%" class="form">Driver's License Required?</td>
    <td width="75%" class="form"><input type="checkbox"
name="driving_required" CHECKED></td></tr>

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 = "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(),'$submitted_by','$sm_description','$responsibilities','$behaviors','$skills','$experience','$requirements')";

$jddresult = 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?

-- 
Jeff Self
Information Technology Analyst
Department of Personnel
City of Newport News
2400 Washington Avenue
Newport News, VA 23607
757-926-6930




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

* Re: Problem involving checkbox and Postgresql
@ 2002-06-20 17:39  Surojit Niyogi <surojit@bungeecode.com>
  parent: Jeff Self <jself@nngov.com>
  0 siblings, 1 reply; 11+ messages in thread

From: Surojit Niyogi @ 2002-06-20 17:39 UTC (permalink / raw)
  To: Jeff Self <jself@nngov.com>; +Cc: pgsql-php

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

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:
>
><tr><td width="25%" class="form">Driver's License Required?</td>
>    <td width="75%" class="form"><input type="checkbox"
>name="driving_required" CHECKED></td></tr>
>
>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 = "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(),'$submitted_by','$sm_description','$responsibilities','$behaviors','$skills','$experience','$requirements')";
>
>$jddresult = 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?
>
>  
>




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

* Re: Problem involving checkbox and Postgresql
@ 2002-06-20 19:01  Jeff Self <jself@nngov.com>
  parent: Surojit Niyogi <surojit@bungeecode.com>
  0 siblings, 5 replies; 11+ messages in thread

From: Jeff Self @ 2002-06-20 19:01 UTC (permalink / raw)
  To: Surojit Niyogi <surojit@bungeecode.com>; +Cc: pgsql-php

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
> 
> 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:
> >
> ><tr><td width="25%" class="form">Driver's License Required?</td>
> >    <td width="75%" class="form"><input type="checkbox"
> >name="driving_required" CHECKED></td></tr>
> >
> >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 = "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(),'$submitted_by','$sm_description','$responsibilities','$behaviors','$skills','$experience','$requirements')";
> >
> >$jddresult = 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 through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
-- 
Jeff Self
Information Technology Analyst
Department of Personnel
City of Newport News
2400 Washington Avenue
Newport News, VA 23607
757-926-6930




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

* Re: Problem involving checkbox and Postgresql
@ 2002-06-20 20:02  Chris Thompson <thompson@ednet.co.uk>
  parent: Jeff Self <jself@nngov.com>
  4 siblings, 1 reply; 11+ messages in thread

From: Chris Thompson @ 2002-06-20 20:02 UTC (permalink / raw)
  To: Jeff Self <jself@nngov.com>; +Cc: Surojit Niyogi <surojit@bungeecode.com>; pgsql-php


Then check if($driving_required==1) { $bleh='t'} else { $bleh='f'}

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
> >
> > 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:
> > >
> > ><tr><td width="25%" class="form">Driver's License Required?</td>
> > >    <td width="75%" class="form"><input type="checkbox"
> > >name="driving_required" CHECKED></td></tr>
> > >
> > >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 = "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(),'$submitted_by','$sm_description','$responsibilities','$behaviors','$skills','$experience','$requirements')";
> > >
> > >$jddresult = 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 through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo@postgresql.org so that your
> > message can get through to the mailing list cleanly
> --
> Jeff Self
> Information Technology Analyst
> Department of Personnel
> City of Newport News
> 2400 Washington Avenue
> Newport News, VA 23607
> 757-926-6930
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
> --
> Virus scanned by edNET.
>

-- 

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender. Any
offers or quotation of service are subject to formal specification.
Errors and omissions excepted.  Please note that any views or opinions
presented in this email are solely those of the author and do not
necessarily represent those of edNET or lightershade ltd. Finally, the
recipient should check this email and any attachments for the presence of
viruses.  edNET and lightershade ltd accepts no liability for any damage
caused by any virus transmitted by this email.

-- 
-- 
Virus scanned by edNET.



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

* Re: Problem involving checkbox and Postgresql
@ 2002-06-20 20:08  Keary Suska <hierophant@pcisys.net>
  parent: Jeff Self <jself@nngov.com>
  4 siblings, 0 replies; 11+ messages in thread

From: Keary Suska @ 2002-06-20 20:08 UTC (permalink / raw)
  To: pgsql-php

on 6/20/02 1:01 PM, jself@nngov.com purportedly said:

> 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

if( ! $driving_required ) $driving_required = 'f';

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"




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

* Re: Problem involving checkbox and Postgresql
@ 2002-06-20 20:11  Chadwick Rolfs <cmr@shell.gis.net>
  parent: Jeff Self <jself@nngov.com>
  4 siblings, 0 replies; 11+ messages in thread

From: Chadwick Rolfs @ 2002-06-20 20:11 UTC (permalink / raw)
  To: pgsql-php

I find that an if() statement helps quite a bit.
Example:

if ($driving_required = 'on')
{
  $driving_required = 1;
}
else
{
  $driving_required = 0;
}

Also keep in mind that you can always manipulate ALL of your $_POST or
$_GET variables through a foreach() loop and a bunch of if() statements...

Hope this helps:)

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
> > 
> > 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:
> > >
> > ><tr><td width="25%" class="form">Driver's License Required?</td>
> > >    <td width="75%" class="form"><input type="checkbox"
> > >name="driving_required" CHECKED></td></tr>
> > >
> > >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 = "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(),'$submitted_by','$sm_description','$responsibilities','$behaviors','$skills','$experience','$requirements')";
> > >
> > >$jddresult = 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 through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo@postgresql.org so that your
> > message can get through to the mailing list cleanly
> -- 
> Jeff Self
> Information Technology Analyst
> Department of Personnel
> City of Newport News
> 2400 Washington Avenue
> Newport News, VA 23607
> 757-926-6930
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
> 

-Chadwick




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

* Re: Problem involving checkbox and Postgresql
@ 2002-06-20 20:14  Surojit Niyogi <surojit@bungeecode.com>
  parent: Chris Thompson <thompson@ednet.co.uk>
  0 siblings, 0 replies; 11+ messages in thread

From: Surojit Niyogi @ 2002-06-20 20:14 UTC (permalink / raw)
  To: Chris Thompson <thompson@ednet.co.uk>; +Cc: Jeff Self <jself@nngov.com>; pgsql-php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body>
I suppose it works well with radio buttons where you at least have a "Yes"
and "No" option.<br>
<br>
Chris Thompson wrote:<br>
<blockquote type="cite"
 cite="midPine.LNX.4.33L2.0206202101340.24168-100000@boyce.ednet.co.uk">
  <pre wrap="">Then check if($driving_required==1) { $bleh='t'} else { $bleh='f'}

On 20 Jun 2002, Jeff Self wrote:

  </pre>
  <blockquote type="cite">
    <pre wrap="">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:
    </pre>
    <blockquote type="cite">
      <pre wrap="">Hi Jeff,

Set the value parameter in the input tag

&lt;input type="checkbox"
name="driving_required" CHECKED value='1'&gt;

That should work I believe.

-Surojit

Jeff Self wrote:

      </pre>
      <blockquote type="cite">
        <pre wrap="">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:

&lt;tr&gt;&lt;td width="25%" class="form"&gt;Driver's License Required?&lt;/td&gt;
   &lt;td width="75%" class="form"&gt;&lt;input type="checkbox"
name="driving_required" CHECKED&gt;&lt;/td&gt;&lt;/tr&gt;

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 = "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(),'$submitted_by','$sm_description','$responsibilities','$behaviors','$skills','$experience','$requirements')";

$jddresult = 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?



        </pre>
      </blockquote>
      <pre wrap="">
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to <a class="moz-txt-link-abbreviated" href="mailto:majordomo@postgresql.org">majordomo@postgresql.org</a> so that your
message can get through to the mailing list cleanly
      </pre>
    </blockquote>
    <pre wrap="">--
Jeff Self
Information Technology Analyst
Department of Personnel
City of Newport News
2400 Washington Avenue
Newport News, VA 23607
757-926-6930


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to <a class="moz-txt-link-abbreviated" href="mailto:majordomo@postgresql.org">majordomo@postgresql.org</a> so that your
message can get through to the mailing list cleanly
--
Virus scanned by edNET.

    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
</blockquote>
</body>
</html>




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

* Re: Problem involving checkbox and Postgresql
@ 2002-06-20 20:22  Scott Marlowe <scott.marlowe@ihs.com>
  parent: Jeff Self <jself@nngov.com>
  4 siblings, 1 reply; 11+ messages in thread

From: Scott Marlowe @ 2002-06-20 20:22 UTC (permalink / raw)
  To: Jeff Self <jself@nngov.com>; +Cc: Surojit Niyogi <surojit@bungeecode.com>; pgsql-php

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
> > 
> > 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:
> > >
> > ><tr><td width="25%" class="form">Driver's License Required?</td>
> > >    <td width="75%" class="form"><input type="checkbox"
> > >name="driving_required" CHECKED></td></tr>
> > >
> > >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 = "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(),'$submitted_by','$sm_description','$responsibilities','$behaviors','$skills','$experience','$requirements')";
> > >
> > >$jddresult = 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 through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo@postgresql.org so that your
> > message can get through to the mailing list cleanly
> 

-- 
"Force has no place where there is need of skill.", "Haste in every 
business brings failures.", "This is the bitterest pain among men, to have 
much knowledge but no power." -- Herodotus





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

* Re: Problem involving checkbox and Postgresql
@ 2002-06-21 13:44  Chadwick Rolfs <cmr@shell.gis.net>
  parent: Digital Wokan <wokan@cox.net>
  0 siblings, 0 replies; 11+ messages in thread

From: Chadwick Rolfs @ 2002-06-21 13:44 UTC (permalink / raw)
  To: pgsql-php

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




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


end of thread, other threads:[~2002-06-21 13:44 UTC | newest]

Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-06-20 16:36 Problem involving checkbox and Postgresql Jeff Self <jself@nngov.com>
2002-06-20 17:39 ` Surojit Niyogi <surojit@bungeecode.com>
2002-06-20 19:01   ` Jeff Self <jself@nngov.com>
2002-06-20 07:57     ` David C. Brown <dbrown@centennialwines.com>
2002-06-20 20:02     ` Chris Thompson <thompson@ednet.co.uk>
2002-06-20 20:14       ` Surojit Niyogi <surojit@bungeecode.com>
2002-06-20 20:08     ` Keary Suska <hierophant@pcisys.net>
2002-06-20 20:11     ` Chadwick Rolfs <cmr@shell.gis.net>
2002-06-20 20:22     ` Scott Marlowe <scott.marlowe@ihs.com>
2002-06-17 21:03       ` Digital Wokan <wokan@cox.net>
2002-06-21 13:44         ` Chadwick Rolfs <cmr@shell.gis.net>

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