The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
Problem w/server-side validation - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Modules / Other (https://forums.formtools.org/forumdisplay.php?fid=8) +--- Forum: Form Validation: JS + PHP (https://forums.formtools.org/forumdisplay.php?fid=18) +--- Thread: Problem w/server-side validation (/showthread.php?tid=385) |
Problem w/server-side validation - aalsmo - Dec 5th, 2009 I want to make some fields required and validate the e-mail address. After implimenting the code as described in the documentation area, I am receiving an error "inside" the form field before I even submit anything. Here is my form code: PHP Code: <?php The error I'm getting when I goto this form to start filling it out is: (this is the name field) Code: <br /><b>Notice</b>: Undefined index: name in <b>D:\Hosting\4885718\html\application\application.php</b> on line <b>80</b><br /> Line 80 in my form reads: Code: <td width="312"><input type="text" name="name" id="name" value="<?=htmlspecialchars($fields["name"])?>"></td> Any help you can offer would be greatly appreciated. RE: Problem w/server-side validation - Ben - Dec 6th, 2009 Hi Aalsmo, You'll see those notices when your error reporting is set quite high. This particular message just means that the $fields variable doesn't have a "name" key. No big deal! By default, Form Tools is configured to show ALL errors - even minor notices & warnings like this one. There's two ways to fix it. 1. Suppress the error by adding a "@" symbol before the variable, like so: Code: <td width="312"><input type="text" name="name" id="name" value="<?=htmlspecialchars(@$fields["name"])?>"></td> (notice the @$fields["name"] bit). 2. Alternatively, you can add the following line to your global/config.php file: PHP Code: $g_default_error_reporting = 1; That will prevent ALL minor errors like this one from showing up and only show genuine "error" errors. All the best - Ben |