[FX.php List] Undefined Index Error
Steve Winter
steve at bluecrocodile.co.nz
Mon Aug 13 10:08:28 MDT 2007
Hi Patricia,
I presume that this is an index in $_REQUEST or $_POST.
Basically what's happening here is if the checkbox isn't checked, then there
is no 'value' for BasicSvc_Features.
If you had a regular input field, then it would be something like;
<input type="text" name="BasicSvc_Features" value="" />
So you're explicitly defining the presence of that variable, but giving it
an initial null value, so it is defined, but has no value...
With a check box, if the box isn't checked, then when the form is submitted,
its name is not parsed in as it has no value associated with it... try doing
a print_r($_REQUEST) and you'll see that un-checked check boxes aren't in
that list...
Two solutions spring to mind;
1. check and see if the variable is defined before trying to use it;
if(isset($_REQUEST['BasicSvc_Features'])) { // whatever }
2. define an 'unchecked' value in your form,
<input type="hidden" name="BasicSvc_Features"
id="BasicSvc_Features_unchecked" value="no" />
<input type="checkbox" name="BasicSvc_Features"
id="BasicSvc_Features_checked" value="yes" />
This way, BasicSvc_Features will always have a value associated with it,
either no, if the box isn't checked, or yes if the box is. Then on your
submission page you can decided what to do based on its value...
Hope this makes sense... let me know if not, or you have problems..
Cheers
Steve
-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org
[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of VanBuskirk,
Patricia
Sent: Monday, 13 August 2007 4:43 p.m.
To: FX.php Discussion List
Subject: [FX.php List] Undefined Index Error
Has anyone else had any problems using php with FMP 9 in getting the
following type error:
Notice: Undefined index: BasicSvc_Features in
C:\Inetpub\wwwroot\Forms\TSR\orderconfirm.php on line 14
NOTE: I only receive this error if any CHECKBOXES are left unchecked on
the form. Then I will receive one line for each checkbox left
unchecked. Any other type field left blank will not produce this error.
_______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.15/949 - Release Date: 12/08/2007
11:03 a.m.
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.15/949 - Release Date: 12/08/2007
11:03 a.m.
More information about the FX.php_List
mailing list