MSUK1 Posted January 12, 2011 Share Posted January 12, 2011 i am using the following to validate a submission form. when i take this validation script out, the php script works fine, however when i use it it redirects to index.html as if their was an error.... please can somebody help, ive tried and cannot see the problem? $fname = $_POST['firstname']; $lname = $_POST['lastname']; $add1 = $_POST['add1']; $add2 = $_POST['add2']; $city = $_POST['city']; $county = $_POST['county']; $country = $_POST['country']; $postcode = $_POST['postcode']; $email1 = $_POST['email1']; $email2 = $_POST['email2']; $mobile = $_POST['mobile']; $home = $_POST['home']; $time = $_POST['time']; $answer = $_POST['answer']; $job = $_POST['job']; $ip = $_SERVER['REMOTE_ADDR']; // validation $validationOK=true; if (Trim($fname)=="") $validationOK=false; if (Trim($lname)=="") $validationOK=false; if (Trim($add1)=="") $validationOK=false; if (Trim($city)=="") $validationOK=false; if (Trim($county)=="") $validationOK=false; if (Trim($country)=="") $validationOK=false; if (Trim($postcode)=="") $validationOK=false; if (Trim($email1)=="") $validationOK=false; if (Trim($email2)!=="$email1") $validationOK=false; if (Trim($mobile)=="") $validationOK=false; if (Trim($time)=="") $validationOK=false; if (Trim($answer)!=="34") $validationOK=false; if (Trim($job)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=index.html\">"; exit; } Link to comment https://forums.phpfreaks.com/topic/224244-validation/ Share on other sites More sharing options...
BlueSkyIS Posted January 12, 2011 Share Posted January 12, 2011 echo out the values to see which one(s) fail the tests. echo "fname: $fname <br />"; echo "lname: $lname <br />"; // etc. Link to comment https://forums.phpfreaks.com/topic/224244-validation/#findComment-1158616 Share on other sites More sharing options...
MSUK1 Posted January 12, 2011 Author Share Posted January 12, 2011 have figured the error! Next problem, is their a way next to each validation check to return a value say answer !="34" so set answer to wrong, and redirect to index.html?a=false Link to comment https://forums.phpfreaks.com/topic/224244-validation/#findComment-1158618 Share on other sites More sharing options...
BlueSkyIS Posted January 12, 2011 Share Posted January 12, 2011 yes, just replace or add to the condition inside the if() if (Trim($postcode)=="" || $postcode != 34) Link to comment https://forums.phpfreaks.com/topic/224244-validation/#findComment-1158622 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.