Get query for URL Rotator

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
legionarius
Forum Newbie
Posts: 3
Joined: Sat Mar 27, 2010 2:49 pm

Get query for URL Rotator

Post by legionarius »

usually i use this at the end of a link to pass the s,p,x,hid vars

index.php?S=<?php echo $_GET['S']?>&P=<?php echo $_GET['P']?>&X=<?php echo $_GET['X']?>&hid=<?php echo $_GET['hid']?>

but i now i am using a URL rotator and need to still pass these vars. How do i do that with the current script i am using:

Code: Select all

<?php


$sites[0] = array("www.mysite.com/index.php?", 5);
$sites[1] = array("www.myothersite.com/traffic.asp?", 1);

$countsites = count($sites);

for($i=0; $i<$countsites; $i++)
{
for($x=0; $x<$sites[$i][1]; $x++)
{
$mylist[] = array($sites[$i][0]);
}
}

$countlist = count($mylist);

$countlist = $countlist - 1;

$picker = rand(0, $countlist);

$picked = $mylist[$picker][0];

header("Location: http://" . $picked);

?>
Thanks
-Hector
User avatar
andyhoneycutt
Forum Contributor
Posts: 468
Joined: Wed Aug 27, 2008 10:02 am
Location: Idaho Falls

Re: Get query for URL Rotator

Post by andyhoneycutt »

Maybe I'm missing something, but I don't believe you'd do it any different. Can you not attach the $_GET params to the end of the url you are redirecting to? For example:

Code: Select all

header("Location: $some_url?S={$_GET['S']}&P={$_GET['P']}&X={$_GET['X']}&hid={$_GET['hid']}");
exit; 
-Andy
Post Reply