note 44211 added to reserved.variables
| From: | info at gjbdesign dot com | Date: | Sun, 18 Jul 2004 11:41:04 +0000 |
| Subject: | note 44211 added to reserved.variables | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-73475@lists.php.net to get a copy of this message | ||
if you want a good, short way to check to see if all a form's fields have been filled in, then
you can check it this way.
<?php
function GJB_Form_Check($GJB_form_vars){
/*test that each variable has a value*/
foreach ($GJB_form_vars as $key => $value){
if (!isset($key) || empty($value)){
return false;
}
}
return true;
}
if(isset($cmdPost){/*prevents code below from running unless form is submitted*/
if(!GJB_Form_Check($_POST)){
echo"Not all fields are filled out.";/*Not filled out*/
}else{
echo"All ok";/*All filled out*/
}
}
?>
An example form for this function is as follows:
<form method="post" action="">
<input type="text" name="user"
value="<?=$_POST['user']?>" /><br />
<input type="text" name="pass"
value="<?=$_POST['pass']?>" /><br />
<input type="submit" value="Submit" name="cmdPost" />
</form>
----
Manual Page -- http://www.php.net/manual/en/reserved.variables.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44211
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44211&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44211&report=yes
Search -- http://master.php.net/manage/user-notes.php