php Forward Script

Are you looking for a simple script to forward visitors to a new page?  How about have them see the old page and meScripts Gurusmo to update
their bookmarks or show a disclaimer before they are forwarded.  This snazzy little piece of code will do that and even forward to one random page out of the ones that you designate.

 

<?php

$r=rand(1,5);
//  echo any information to the browser then forward

sleep(3); // seconds to pause.
if($r==1)
header(“Location: http://your destination site address”);
if($r==2)
header(“Location: http://your destination site address”);
if($r==3)
header(“Location: http://your destination site address”);
if($r==4)
header(“Location: http://your destination site address”);
if($r==5)
header(“Location: http://your destination site address”);

exit;

?>

A site about private charter jets would benefit from this type of script.  Let’s assume that the site owner wanted to have a simple way to advertise and rotate banners.  He/she could have one lead generation source and direct those leads to 1 of 5 different full-fillers.  As a user visited the site and looked for a particular flight to book, the script would be available behind the banner or text link to one of the advertisers.  If the traveler clicks on the link it will randomly select, show the disclaimer, then forward the link as selected.

The header() function also has the ability to forward with the association of the type of forward.  It isn’t really that much of a use in this usage on a travel site and for this purpose but it may help if you were going to move a site and needed to let the search engines know that the forward was because the page had permanently moved.

Use this for “AB” testing.  If you are running a campaign and want to see which form works better and provides more leads or conversions, use this script to test which one randomly converts.  It is also great for affiliate links and testing which advertisers do a better job of converting the traffic you send them.  I would think that even a kickstarter campaign would be able to make use of this simple 20 line code.

Enjoy and good coding.

Comments Off on php Forward Script

Filed under Uncategorized

Comments are closed.