Forum Moderators: coopster
I have been researching the header location function and I can't seem to find an answer to my question. I do not know if I am asking this right, but is there a way to do this...
Say you have your site http://example.com
Whenever a user clicks a game, he goes to example.com/game/...
When the user clicks the "play game" button, he goes to play the game at say example.com/playgame/...
Now there are multiple games on the site so every game goes from arcade.com/game/... to example.com/playgame/...
Is there a way to use the header location function to send a user to multiple sites?
For example... The user is at example.com/game/1. He clicks the game and is forwarded on to another site to play the game. A different user is also on and is at example.com/game/2. He clicks the game to play and is forwarded on to a different site to play his game.
Is there a way to do this using the header location function? If so, where could I read up more about it?
Thanks for the help,
Eric
[edited by: eelixduppy at 8:25 pm (utc) on Nov. 28, 2008]
[edit reason] exemplified [/edit]
If you have your criteria, this is roughly as follows:
switch ($condition){
case a:
$loc = "http://www.site1.com/game1/";
break;
case b:
$loc = "http://www.site2.com/game1/";
break;
//etc
default:
$loc = "http://www.siteX.com/gameX/";
}
header("Location: $loc");
exit;
If this is the case, would the above code do this or is there something else that I would need?
<?php
if($playgame)
{
$playgame = "http://www.mysite.com/playgame.php?id=123";
$url = "http://www.example.com";
header("location: $url");
}
Here is what I get stuck. I want the next part of the code to keep the user at my site and let them play the game on my site. So is there some else function I could include such as...
else
{
header("location: Keep the person at my site");
exit/break; (whichever would be best)
Obviously, as I said, I am not very good with php, so I understand most of this doesn't work. I am just looking for a direction to go in.
Thanks,
Eric
What you are looking for is some form of a proxy system - a simple one would run:
print file_get_contents($_GET['realurl']); Where a visitor to:
http://example.com/blah.php?realurl=http://foo.bar/game
Would see the content of foo.bar/game, but the URL remaining within example.com
However - I don't recommend this - and it opens up big holes for copyright liability and being abused by black-hat SEO companies.
<?php
if ($_SERVER['REQUEST_URL'] == 'http://www.example1.com/playgame.php?id=251') {
header('Location: [example2.com...]
}
?>
However - I still don't know what's wrong with giving them a direct link, as the moment they click your one they will go to the other guy's site anyway - and that includes their URL bar changing to his site.
Is this so they don't know they are going to be sent away?
My script was purchased so its more advanced than what I know. It connects to my database and finds the correct game to play and what not. I don't know how to define a direct link for a specific game using the script I have, thats all. So I just decided that using the header location function would be easiest for me.