Re: Fw: [PHP] Re:[PHP]question

From: Date: Wed, 11 Sep 2002 22:33:55 +0000
Subject: Re: Fw: [PHP] Re:[PHP]question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116052@lists.php.net to get a copy of this message
Hi Meltem, the second one was a better description of your problem. Attached is the most convenient approach can come up with for this problem. It is not optimized, but should be easy to understand. Timo <?php $submitted = isset($_REQUEST['a']); // submitting data or just retrieving page? if($submitted) $fields_complete = ($_REQUEST['a'] && $_REQUEST['b'] && $_REQUEST['c']); // are all fields filled? if(!$submitted) { $f_a_def = ""; $f_a_err = ""; $f_b_def = ""; $f_b_err = ""; $f_c_def = ""; $f_c_err = ""; }; if($submitted && !$fields_complete) { if($_REQUEST['a']) { $f_a_def = $_REQUEST['a']; $f_a_err = "";} else { $f_a_def = ""; $f_a_err = "you forgot to fill this field";}; if($_REQUEST['b']) { $f_b_def = $_REQUEST['b']; $f_b_err = "";} else { $f_b_def = ""; $f_b_err = "you forgot to fill this field";}; if($_REQUEST['c']) { $f_c_def = $_REQUEST['c']; $f_c_err = "";} else { $f_c_def = ""; $f_c_err = "you forgot to fill this field";}; }; if(!$submitted || !$fields_complete) { echo (' <form name="myform" action="'.$_SERVER['PHP_SELF'].'" method="get"> <input name="a" type="text" size="20" value="'.$f_a_def.'"> '.$f_a_err.'<br> <input name="b" type="text" size="20" value="'.$f_b_def.'"> '.$f_b_err.'<br> <input name="c" type="text" size="20" value="'.$f_c_def.'"> '.$f_c_err.'<br> <input value="submit" type="submit" onClick="self.location.href=\'\'"> </form> '); }; if(@$fields_complete) { echo ("all fields filled"); }; ?>

« previous php.general (#116052) next »