Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.