Jochem Maas wrote:
Afan Pasalic schreef:
Andrew Ballard wrote:
On Thu, Mar 12, 2009 at 3:05 PM, Jason Todd Slack-Moehrle
<> wrote:
Hi All,

I have an input field with type="password".

I am trying to do some error checking to see if the user puts a value in
after they submit the form (i.e not left it blank)

Here is what I have:

on form:
Password: <input id="PASSWORD" name="PASSWORD" type="password"

In PHP error checking:

if (empty($_POST[PASSSWORD]))

even though I am putting characters in the field before I submit I am
getting TRUE returned.

This same tactic works for other fields I have that I need to make
sure they
put values in, just I have never done this before with a password field.

What am I doing wrong? I just want to make sure they put something

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']))


try if trim() gives you any different result:

if (empty(trim($_POST['PASSWORD'])))

definitely gives a different result.

$ php -r '
$r = "  "; var_dump(empty(trim($r)));'
PHP Fatal error:  Can't use function return value in write context in Command 
line code on line 2

you can only pass variables to empty() *not* expressions.


yup... didn't think that way...
though, I was giving an idea

$password = trim($_POST['PASSWORD']);
if (empty($password)


PHP General Mailing List (
To unsubscribe, visit:

Reply via email to