Re: password field validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 12, 2009 at 3:39 PM, Jason Todd Slack-Moehrle
<mailinglists@xxxxxxxxxxxxxxx> wrote:
>>>
>>> if (empty($_POST[PASSSWORD]))
>>> { $GERROR="TRUE";}
>>>
>>
>> If that's a direct copy/paste from your actual code, there is an extra
>> S in PASSWORD. Also, you should enclose the array key in quotes:
>>
>> if (empty($_POST['PASSWORD']))
>> { $GERROR='TRUE'; }
>
> It is official I am a DOPE! Thank you, yes, I did not see the SSS in an hour
> of looking!
>
> Why enclose in quotes? I have never done this!
>
> -Jason
>

If you don't enclose them in quotes, PHP first looks for a constant
with that name. Thus, it the constant PASSWORD was defined as 'some
silly string', your code would evaluate to $_POST['some silly string']
instead of the string 'PASSWORD' that you probably intended it to use.

That, and it generates an E_NOTICE. On a production server, these are
usually hidden from public view, but it is still good practice to
avoid them.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux