I am writing a code that I am sure is very simple, but for some reason I am having trouble. It seems like it would be logical to write it out as it is. If the $_GET != $arr then return false with an error.
The situation is we give two different groups a code, there are three codes in all. The third code is a catch all that takes them to a form that is un-modified, so it is an initial value or will be. The other two take them to two different forms that is assigned to each code.
What I am trying to get to do is if they enter the code correct then fine it redirects them, if they do not enter anything they get an error that says sorry you must enter your code. If they enter it wrong an error that says check your code and try again or call this number for help.
The error is where I am having trouble creating. If you would help me figure out how to validate the $_GET form to the arrays and if it comes out false to pop out the error.
<?php
$arr = array(001,002,003);
if ($_GET['code'] === "001") {
header("Location: http://stackoverflow.com/");
}
if ($_GET['code'] === "002") {
header("Location: http://gaming.stackexchange.com/");
}
if ($_GET['code'] === "003") {
header("Location: http://gamedev.stackexchange.com/");
}
if ($_GET ['code'] != $arr);
else {
echo("Uh oh, you did not enter the correct code error message");
}
?>
</head>
<body>
<form id="galaonly" name="galaonly" method="get" action="">
<input name="code" type="text" value="001" size="50" maxlength="150" />
<input type="submit" value="Submit" />
</form>
1 Answer