Thread Options if accessing site from ?action=0 it will take to a different page from ?ac

Josh-Emm

Registered Member
Joined
Apr 12, 2011
Messages
61
Reaction score
13
Ok to start of I know none PHP and i want people who access my site from the url http://WWW.EXAMPLE.COM/?action=0 to be taken to a different page from what you would if you accessed it from ?action=1 this is probs so easy but i have been searching for a day how to do it cant find anything :(
 
PHP:
<?php
/**
 * if url parameter 'action' is set,
 * then decide where to redirect
 */
if (isset($_GET['action'])) {
	if ($_GET['action'] == 1) {
		header("Location: http://www.url1.com/");
	} elseif ($_GET['action'] == 2) {
		header("Location: http://www.url2.com/");
	} elseif ($_GET['action'] == 3) {
		header("Location: http://www.url3.com/");
	} else {
		echo "Action \"".$_GET['action']."\" was not found.";
	}
} else {
	echo "'Action' parameter is not set.";
}
?>
 
^that is one way, or simply a switch.
PHP:
<?php
switch($_GET['id']){
    case 0:
header("Location: website");
        break;
    case 1:
header("Location: website");
        break;
    case 2:
header("Location: website");
        break;
default:
header("Location: website");
}
?>
where default would be the page it will go to if there is none set.

you would call it like id=1 etc etc.
both will work, i've always used switches but to each their own
 
Back
Top