Jump to content

Trying to duplicate a php script in an opposite manner


abcd

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.