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");
};

?>


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

Reply via email to