[PHP] Re: how to check the form filled all

2004-01-26 Thread jsWalter
You might want to think about client side validation as well.

This infomrs the user of any probelms *before* it hits your server.

Now, this does *not* remove the step of form value checking on the server.

Check out...

http://groups.yahoo.com/group/javascript_validation/

A nice little client-side validation class, cross browser.

Hope this helps.

Walter

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



[PHP] Re: how to check the form filled all

2004-01-19 Thread Chris W
Sungpill Han wrote:

HI, i want to check if the user filled the all inputs in the form. So, I
checked NULL and  with this function in the post receiving script.
---
function is_filled_out()
{
 // test that each variabl has a value
 foreach($_POST as $key = $value)
 {
  if(is_null($value) || $value=)
   return false;
 }
 return true;
}
-
but when I submit the form without putting any value, it returns 'true'.
what's wrong with my code?
It is my understanding (not sure if it is correct though) that if your 
form has a field named x and the user does not enter any value in that 
field, there will be no entry for field x in the $_POST array.   so your 
loop should never return false.  To see if they entered a value in field 
X  you need to code something like this

if(! $_POST['x']){
  do what ever you do when they don't fill out a required field;
}
Chris W

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


Re: [PHP] Re: how to check the form filled all

2004-01-19 Thread John W. Holmes
Chris W wrote:

Sungpill Han wrote:

HI, i want to check if the user filled the all inputs in the form. So, I
checked NULL and  with this function in the post receiving script.
---
function is_filled_out()
{
 // test that each variabl has a value
 foreach($_POST as $key = $value)
 {
  if(is_null($value) || $value=)
= is assignment, == is equality...

if(is_null($value) || $value==)

or, since the value will never be null if it's already in $_POST

if($value=='')

I would recommend empty(), but if someone puts 0 (zero) in a field, 
empty(0) returns true...

   return false;
 }
 return true;
}
-
but when I submit the form without putting any value, it returns 'true'.
what's wrong with my code?


It is my understanding (not sure if it is correct though) that if your 
form has a field named x and the user does not enter any value in that 
field, there will be no entry for field x in the $_POST array.   
This depends on the field. If it's a text box, then x will still be in 
$_POST, but it'll be empty. If it's a checkbox, and the checkbox is not 
checked, then x will not be in $_POST.

One thing to note for the original poster, all your code does is check 
that there are no empty values within $_POST. it doesn't keep track of 
how many there are or if the correct ones are there. If I make my own 
form with a single text box that I put a value in, it'll be validated by 
your code. Hopefully there's more to your validation than this. :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals  www.phparch.com

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