jscix Posted February 11, 2007 Share Posted February 11, 2007 Okay, there is no problems in the code, it all works, however.. I know there has to be a better way. What I want to know is: --How could I check the values of two text feilds, and basically print an error message if they dont meet a certain criteria. --IF they do meet the criteria, then perform the next step in the code. You can see how I did this below, but I want to refine it to check for a bit more than just a (NULL) Value. The way it is now, is sloppy/ineffeciant.. anyone have some pointers? <?php require "forms.php"; $usrfeild = $_GET["usrfeild"]; $pwfeild = $_GET["pwfeild"]; if ($usrfeild == (NULL)) { $a = "0"; print "Please enter a username!"; die(); } else { $a = "1"; } if ($pwfeild == (NULL)) { $b = "0"; print "Please enter a password!"; die(); } else { $b = "1"; } $bothh = ($a + $b); if ($bothh="2"){ require "list.php"; } else { print "Enter User/PW"; } Quote Link to comment Share on other sites More sharing options...
almightyegg Posted February 11, 2007 Share Posted February 11, 2007 if(!$usrfield){ //error }elseif(!$pwfield){ //error2 }else{ //perform action } Quote Link to comment Share on other sites More sharing options...
jscix Posted February 11, 2007 Author Share Posted February 11, 2007 Hrmm, I could use the elseif statements indefinitly to errorhandle everything I want to check for correct? I will try this, tyvm. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.