Recent Posts

Sponsors
![]() |
How to: Prevent Direct Access to upsell pagesDawn Rossi, 05-28-2009 |
Our information-marketing clients sales-process typically follows these steps:
Page 1: Opt-in page
Page 2: Sales letter
Page 3: Checkout form
Page 4: Upsells 1,2,3 etc.
Page 5: Thank you page
How do you prevent users from directly accessing anything but page 1?
You could use cookies or session variables, but the easiest way to block users from directly accessing any "pages in the middle", is to validate using the HTTP_REFERER string (what url the user came from).
If the user is directly hitting pages 2 to 5, or arriving there from any third party sites, the HTTP_REFERER string will not match your domain. You can then redirect the user back to Page 1 and force following the process as it was intended.
The code below does the trick:
$referring_host = parse_url($_SERVER['HTTP_REFERER']);
$referring_host = $referring_host['host'];
if (Strcasecmp($referring_host,$_SERVER['HTTP_HOST'])!=0)
{
// We got here from a different domain (or bookmark)
// Redirect to page 1
Header("Location: page1");
die;
}
If you're using the SoftwareProjects Shopping Cart, the above can be implemented with a single call to do_blockdirectlinking
Example:
// Include SPI shopping cart
require_once("spicart.php");
// Block direct access to this page
do_blockdirectlinking();
Page 1: Opt-in page
Page 2: Sales letter
Page 3: Checkout form
Page 4: Upsells 1,2,3 etc.
Page 5: Thank you page
How do you prevent users from directly accessing anything but page 1?
You could use cookies or session variables, but the easiest way to block users from directly accessing any "pages in the middle", is to validate using the HTTP_REFERER string (what url the user came from).
If the user is directly hitting pages 2 to 5, or arriving there from any third party sites, the HTTP_REFERER string will not match your domain. You can then redirect the user back to Page 1 and force following the process as it was intended.
The code below does the trick:
$referring_host = parse_url($_SERVER['HTTP_REFERER']);
$referring_host = $referring_host['host'];
if (Strcasecmp($referring_host,$_SERVER['HTTP_HOST'])!=0)
{
// We got here from a different domain (or bookmark)
// Redirect to page 1
Header("Location: page1");
die;
}
If you're using the SoftwareProjects Shopping Cart, the above can be implemented with a single call to do_blockdirectlinking
Example:
// Include SPI shopping cart
require_once("spicart.php");
// Block direct access to this page
do_blockdirectlinking();
|

Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments