Re: $_POST array question
..oO(William Gill)
>Michael Fesser wrote:
>> Empty form fields are always submitted, because they actually have a
>> value - an emtpy string. That's different from having no value at all.
>
>I don't remember it working that way in practice
You've already said that ;-), but it always worked that way as far as I
can remember.
>but I may be confusing
>PHP and other script engines (like Python).
Quite possible.
>I guess it doesn't matter
>what I remember or not.
>
>> Such checks (usually with isset()) should always be done.
>Probably right. For some reason I was getting the impression I could
>skip that in lieu of other things, but..
>
>I was adding the following to input fields...
>
>class="<?php echo array_key_exists('First_Name', $form_errors) ? 'error'
>: 'normal'?>" value="<?php echo array_key_exists('First_Name', $_POST)?
> htmlentities( $_POST['First_Name'],ENT_QUOTES) : '' ?>"
>
>... and now I may have to retool my thinking a little. Might be cleaner
>to create a function instead.
Indeed. Such things are done over and over again, so some little er
functions would really make sense here.
Micha
|