I'm passing a variable from one page to the next via a form post. On the next page, the code checks to see if that variable equals a preset value. If not, the code doesn't execute.
$jehosophat = $_POST['variablepassed'];
if ($blahblah == "jehosophat")
{
print "execute code";
}
What about when $blahblah isn't defined such as by a person who accesses the page without coming through the form? The code won't execute, but I also don't want the page to return an error and I want to send the user somewhere else.
In Code Fusion, I protected against this by using:
if (isDefined($blahblah))
code to execute
end if
Using PHP on our Linux server, I tried using
$jehosophat = $_POST['variablepassed'];
if (defined($jehosophat))
{
if ($blahblah == "jehosophat"){print "execute code";}
else{other code;}
}
else
{
print "Get Out!";
}
but it never qualified $jehosophat as defined even when it was. What am I doing wrong and is there a better code to use?
Brian