Re: IF ELSEIF ELSE??
| From: | Joel Ricker | Date: | Sat, 04 Aug 2001 05:42:09 +0000 |
| Subject: | Re: IF ELSEIF ELSE?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-61223@lists.php.net to get a copy of this message | ||
example something you might
> want to look at the type of data the person is entering, a little
> validation. I hope that helps.
Right. And if you'ld like here is something I came up with recently that I
kind of liked that you could use if you want. I'd like other peoples
opinions as well as to what I'm doing:
switch ( [posted form submit name] ) {
case ( [posted form submit value] ):
if (error check form value) {
$Error["aname"] = 1;
print [Error in form value];
}
if (error check another form value) {
$Error["anothername"] = 1;
print [Error in another form value];
}
if (count($Error) == 0) {
process form values
do something or show a new page
break;
}
default:
Show form
[I use the error values to highlight bad form entries like: ]
if ($Error["Name"]) {
?><font color=#FF0000>Name</font><?
} else {
?>Name<?
break;
}
So basically the result of this is, if the enter a bad form value after
submission, it prints out the errors, skips the processing block and since
there was no break, it continues through to the default block and reshows
the form for resubmission.
What do you think?
Joel