[PHP] password field validation

2009-03-12 Thread Jason Todd Slack-Moehrle

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  
size=15


In PHP error checking:

if (empty($_POST[PASSSWORD]))
{ $GERROR=TRUE;}

even though I am putting characters in the field before I submit I am  
always 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  
there!


-Jason 


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



Re: [PHP] password field validation

2009-03-12 Thread Andrew Ballard
On Thu, Mar 12, 2009 at 3:05 PM, Jason Todd Slack-Moehrle
mailingli...@mailnewsrss.com 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 size=15

 In PHP error checking:

 if (empty($_POST[PASSSWORD]))
 { $GERROR=TRUE;}

 even though I am putting characters in the field before I submit I am always
 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 there!

 -Jason

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'; }


Andrew

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



Re: [PHP] password field validation

2009-03-12 Thread Daniel Brown
On Thu, Mar 12, 2009 at 15:05, Jason Todd Slack-Moehrle
mailingli...@mailnewsrss.com wrote:

 if (empty($_POST[PASSSWORD]))
 { $GERROR=TRUE;}
[snip!]

 What am I doing wrong?

Spelling.

Password only has two S's.


-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] password field validation

2009-03-12 Thread Afan Pasalic



Andrew Ballard wrote:

On Thu, Mar 12, 2009 at 3:05 PM, Jason Todd Slack-Moehrle
mailingli...@mailnewsrss.com 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 size=15

In PHP error checking:

if (empty($_POST[PASSSWORD]))
{ $GERROR=TRUE;}

even though I am putting characters in the field before I submit I am always
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 there!

-Jason



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'; }


Andrew

  


try if trim() gives you any different result:

if (empty(trim($_POST['PASSWORD'])))
{ $GERROR='TRUE'; }

afan



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



Re: [PHP] password field validation

2009-03-12 Thread Jason Todd Slack-Moehrle


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

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



Re: [PHP] password field validation

2009-03-12 Thread Jochem Maas
Afan Pasalic schreef:
 
 
 Andrew Ballard wrote:
 On Thu, Mar 12, 2009 at 3:05 PM, Jason Todd Slack-Moehrle
 mailingli...@mailnewsrss.com 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
 size=15

 In PHP error checking:

 if (empty($_POST[PASSSWORD]))
 { $GERROR=TRUE;}

 even though I am putting characters in the field before I submit I am
 always
 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
 there!

 -Jason
 

 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'; }


 Andrew

   
 
 try if trim() gives you any different result:
 
 if (empty(trim($_POST['PASSWORD'])))
 { $GERROR='TRUE'; }


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.



 
 afan
 
 
 


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



Re: [PHP] password field validation

2009-03-12 Thread haliphax
On Thu, Mar 12, 2009 at 2:39 PM, Jason Todd Slack-Moehrle
mailingli...@mailnewsrss.com 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!

Because if it's not in quotes, you run the risk of colliding with one
of PHP's reserved words/constants/etc.


-- 
// Todd

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



Re: [PHP] password field validation

2009-03-12 Thread Afan Pasalic



Jochem Maas wrote:

Afan Pasalic schreef:
  

Andrew Ballard wrote:


On Thu, Mar 12, 2009 at 3:05 PM, Jason Todd Slack-Moehrle
mailingli...@mailnewsrss.com 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
size=15

In PHP error checking:

if (empty($_POST[PASSSWORD]))
{ $GERROR=TRUE;}

even though I am putting characters in the field before I submit I am
always
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
there!

-Jason



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'; }


Andrew

  
  

try if trim() gives you any different result:

if (empty(trim($_POST['PASSWORD'])))
{ $GERROR='TRUE'; }




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)
{ $GERROR='TRUE'; }


;-)



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



Re: [PHP] password field validation

2009-03-12 Thread Andrew Ballard
On Thu, Mar 12, 2009 at 3:39 PM, Jason Todd Slack-Moehrle
mailingli...@mailnewsrss.com 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



Re: [PHP] password field validation

2009-03-12 Thread Afan Pasalic



haliphax wrote:

On Thu, Mar 12, 2009 at 2:39 PM, Jason Todd Slack-Moehrle
mailingli...@mailnewsrss.com 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!



Because if it's not in quotes, you run the risk of colliding with one
of PHP's reserved words/constants/etc.


I would use

$GERROR = false;

if (empty($_POST['PASSWORD']))
{ $GERROR = true;}




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



Re: [PHP] password field validation

2009-03-12 Thread Rodrigo Escares
prueba con trim() :
$pass=trim($_POST[PASSSWORD]);
if (empty($pass))
{
   $GERROR=TRUE;
}

Atte.
Rodrigo
(09) 7 7996571


On Thu, Mar 12, 2009 at 4:05 PM, Jason Todd Slack-Moehrle 
mailingli...@mailnewsrss.com 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 size=15

 In PHP error checking:

 if (empty($_POST[PASSSWORD]))
 { $GERROR=TRUE;}

 even though I am putting characters in the field before I submit I am
 always 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 there!

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




Re: [PHP] password field validation

2009-03-12 Thread Daniel Brown
On Thu, Mar 12, 2009 at 16:04, Rodrigo Escares
rodrigo.esca...@gmail.com wrote:
 prueba con trim() :
 $pass=trim($_POST[PASSSWORD]);
 if (empty($pass))
 {
   $GERROR=TRUE;
 }

Incorrecto, Rodrigo. Tambien, utilice por favor solamente el
ingles en esta lista --- usted puede encontrar la lista de usuario
espanola en:

http://php.net/mailinglists

iGracias!

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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