Originally posted by dotty
I have to redirect users based on the user ID which is passed as a URL query string, so I have something like:
if($_SERVER['QUERY_STRING'] = "PID****")
header ('Location: page1.php);
if($_SERVER['QUERY_STRING'] = "OID****")
header ('Location: page2.php);
else
header ('Location: page3.php);
where the **** are 4 digit variables - so basically any querystring beginning with PID is sent to 'page1.php' and those with OID sent to 'page2.php' and all others to a third page.
Can this be done? Anybody know? [/B]
Dragnovich has given a good and valid reply. The actual answer to your question, of course, is yes. The ways to do it are many, mostly basic string work:
if (stristr("PID", $_SERVER['QUERY_STRING'])) {
header("somepage.php");
} elseif (stristr("PID", $_SERVER['QUERY_STRING'])) {
header("otherpage.php");
}
You probably could also do this with [man]strtok/man, [man]substr/man, and others...