PHP Code Validator

ValleyENT
ValleyENT used Ask the Experts™
on
All,

I have an html form that posts a text input field which should have the following number input before submitting: 45893

After thay submit it posts to process.php then I get the field data $fvalid = $_POST['fvalid']; and i'm trying to make sure they they input the above 5 digit number otherwise it redirects them to an error page for now. This is what I have.

$security=45893;
$validOK=false;
if ($security == $fvalid) $validOK=true;
if ($validOK=true) {
} else {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

If someoen could point me in the right direction that would be great.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Can do like this
<?php
$fvalid = $_POST['fvalid'];

if (substr($fvalid,0,5) == "45893")
{
	echo("Valid");
}
else
{
	// Put redirect code to other page
}
?>

Open in new window

Author

Commented:
Worked like a charm. Thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial