topical media & game development

talk show tell print

professional-search-06-seophp-aff-test.php / php



  <?php
  
  // include URL utils library
  require_once 'include/url_utils.inc.php';
  
  // load configuration script
  require_once 'include/config.inc.php';
  
  // start PHP session
  session_start();
  
  // redirect affiliate links
  if (isset(_REQUEST['aff_id']))
  {
    // save the affiliate ID
    _SESSION['aff_id'] = _REQUEST['aff_id'];
  
    // obtain the URL with no affiliate ID
    clean_url = SITE_DOMAIN . remove_query_param(_SERVER['REQUEST_URI'], 'aff_id');
  
    // 301 redirect to the new URL
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: ' . clean_url);
  }
  
  // display affiliate details
  echo 'You got here through affiliate: ';
  if (!isset(_SESSION['aff_id'])) 
  {
    echo '(no affiliate)'; 
  }
  else
  {
    echo _SESSION['aff_id'];
  }
  
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.