webmaster123 Posted August 5, 2008 Share Posted August 5, 2008 Hi All, I am trying to add some error checking in my php script. I have 2 fields that my members can input a web URL and the text for the URL. I have noticed that some people will input only one of the fields and not the other. Can you tell me how to put in an error checking so both fields are field in? If a member inputs a URL in the URL field then they must also fill in the text field or if they fill in the text field then they must fill in the URL field. If they do not fill in either then no error checking is needed. Here is the php script I tried but it does not work. if ($wtext > 1 || $wurl < 1){ $error = true; $errormessage .= "<center><p class=tbox><b>You did not enter the Website URL.<br>Please enter the Website URL or remove the Website Text.</b></center><br><br>\n"; } if ($wtext < 1 || $wurl > 1){ $error = true; $errormessage .= "<center><p class=tbox><b>You did not enter the Website Text.<br>Please enter the Website text or remove the Website URL.</b></center><br><br>\n"; } Quote Link to comment Share on other sites More sharing options...
btherl Posted August 5, 2008 Share Posted August 5, 2008 Can you post the rest of the script? Quote Link to comment Share on other sites More sharing options...
BioBob Posted August 6, 2008 Share Posted August 6, 2008 Take a look at your bitwise operators. The || means OR. Try && or AND. Probably not useful to you is the ^ operator. One or the other but not both. I dont use that one much, except for regular expressions... if ( (isset($_POST['url'])) || ( (isset($_POST['field1of2'])) && (isset($_POST['field2of2'])) ) ) In this example, URL by itself is acceptable, OR both fileds1 and field2 are required... 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.