any better way...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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) {
     $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?

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux