Re: any better way...
| From: | Kevin Kinsey | Date: | Fri, 21 Apr 2006 03:31:21 +0000 |
| Subject: | Re: any better way... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-234455@lists.php.net to get a copy of this message | ||
benifactor wrote:
I am trying to come up with the best way to check for errors on a form. I have done this before by checking each $_POST variable seperatly but needed a better way that would display more then one error. The following is what i came up with... if (!$condition1 || !$condition2 || $condition1 != $condition2) { if (!$condition1) {Well, the only real *variable* datum there is which condition was broken. So, how about leaving out the HTML construction until after the determination has been made? HTH, KDK -- QOTD: Money isn't everything, but at least it keeps the kids in touch.$regError[0] = "condition 1 not met."; $regErrorc[0] = "<font color=red>"; $regErrore[0] = "</font>"; $regErrord[0] = "<font color=red>***</font>";} else { if (!$condition2) {$regError[1] = "condtion 2 not met."; $regErrorc[1] = "<font color=red>"; $regErrore[1] = "</font>"; $regErrord[1] = "<font color=red>***</font>";} else { if ($condition1 != $condition2) {$regError[0] = "condition 1 is not equal to condition 2"; $regErrorc[0] = "<font color=red>"; $regErrore[0] = "</font>"; $regErrord[0] = "<font color=red>***</font>"; $regErrorc[1] = "<font color=red>"; $regErrore[1] = "</font>"; $regErrord[1] = "<font color=red>***</font>";} } } } which works fine but gets rather lengthy... i was just wondering if there is any better logic to go about this with and if there is could you please enlighten me?