[thelist] php equivavlent to javascript check
M.G.Noriega
manuel at simplelogica.net
Fri Oct 10 04:26:41 CDT 2003
Andrew wrote:
>Hi All where can I find a good resource to chech in PHP the same as this:
>
><
>
function validate(){
// $_POST is a global array containing every variable from your form
if($_POST['BillTo_Name_First'] == ""){
echo 'You cannot leave First Name field empty"';
return false;
}
if($_POST['email'] == ""){
echo 'You cannot leave Email field empty';
return false;
}
txt = $_POST['email'];
if (!strpos(txt)){
echo "This email address seems wrong. Please check the prefix and '@' sign.";
return false;
}
return true;
}
Of course, this is a straight translation . You could do a lot better,
for example, storing every error in an array and, if that array is not
empty after all the checks, stopping the process and showing all the
errors at once.
--
Manuel González Noriega
Simplelógica, construcción web @ http://simplelogica.net
Logicola es el weblog de Simplelógica http://simplelogica.net/logicola/
More information about the thelist
mailing list