[FX.php List] A php question

Leo R. Lundgren leo at finalresort.org
Mon Mar 9 11:08:16 MDT 2009


Well, just as with any input validation, you must be prepared for and  
handle gracefully the situation where you don't get the data that you  
are expecting from the client. One case of that is getting no data at  
all.

To cut it short, one way to solve your problem is to make sure that  
if you don't get a value at all, you place a default value in the  
variable you are working with. For example:

	$DealerType1 = (isset($_REQUEST['DealerType1']) ? $_REQUEST 
['DealerType1'] : '0');
	$request->AddDBParam('DealerType1', $_REQUEST["DealerType1"]);

As I see it, this is only tip of the iceberg for a discussion of best  
practices regarding input handling. But it should be enough to solve  
the problem :)


9 mar 2009 kl. 17.44 skrev John Funk:

> I have a survey form that gets data from existing records, shows  
> the data on form with check boxes. When submitted, edits the FMm data.
>
> When building and testing the site all worked well. This morning I  
> am getting index errors on the edit page because on check boxes  
> that are NOT checked, do not pass the input name (or data) to the  
> post.
>
> Here is my logic on each check box:
>
> I get the data using a normal query:
> $DealerType1=$record['DealerType1'][0];
>
> I how the data in a form:
>
> <?php
> if ($DealerType1 =='Stand-Alone Single')
> echo "<input name= 'DealerType1' type='checkbox' value='Stand-Alone  
> Single' checked />";
> else
> echo "<input name= 'DealerType1' type='checkbox' value='Stand-Alone  
> Single' unchecked />";
> ?>
> A stand-alone business with a single location<br>
>
>
> In my edit.php file that the form calls, this is how I am getting  
> the data:
>
> $request->AddDBParam('DealerType1', $_REQUEST["DealerType1"]);
>
>
> What am I doing wrong? This is an iis web server.
>
> John
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20090309/927dee9b/attachment.html


More information about the FX.php_List mailing list