abcd Posted March 4, 2009 Share Posted March 4, 2009 I have a php script which checks if the visitor has a referer, if there is a referer then the visitor is forwarded to another webpage. If there is no visitor, the php script ends and the html that is on the same script below the php code is displayed to the visitor. Here's an example: <?php if($_SERVER['HTTP_REFERER'] != "") { $random = rand(0, 2); $aff_array = array("http://www.website1.com", "http://website2.com", "http:/website3.com"); header("Location: ".$aff_array[rand(0,2)]); exit(); } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> The above script works fine. However, I'm wondering if it is possible to also reverse the script so it works in an opposite manner? So, let's say the visitor has a referer and is forwarded to the next webpage. Is it possible to setup a php script on the next page which will keep the visitor on the same page if they have a referer and if they do not have a referer it will forward them to another webpage? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/147860-trying-to-duplicate-a-php-script-in-an-opposite-manner/ Share on other sites More sharing options...
RussellReal Posted March 4, 2009 Share Posted March 4, 2009 wow, you're going to send people into an infinate loop of browser redirects.. meanwhile that sounds pretty neat, I don't quite thing the user will approve lol.. you could however, to answer your question, change if ($_SERVER['HTTP_REFERER'] != "") to if ($_SERVER['HTTP_REFERER'] == "") lol Quote Link to comment https://forums.phpfreaks.com/topic/147860-trying-to-duplicate-a-php-script-in-an-opposite-manner/#findComment-776066 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.