View Full Version : Passing affiliate variables from user through .htacess to php then redirect

10-06-2010, 09:11 PM
I am trying to set up a system where to link to my site as an affiliate, all you have to do is click www.mysite.com/pals-xxxxxx (where xxxxxx is the affiliate id). I have set up .htaccess with a quick

RewriteEngine on
RewriteRule ^pals-(.*)$ affpass.php?a=$1
and then in my affpass.php I have
//ini_set('display_errors', '1');
$theURL = getenv("HTTP_REFERER");

srand((double) microtime() * 1000000);

$aff = $_REQUEST['a'];

// redirect to the site now...
header("Refresh: 0; URL=http://newdestination.com/site=mysite&AID=".$aff);

function custom_die($error_msg)
// Nice tidy way of dying
// echo html_header("Unexpected Error");
// echo ss_template('error_die.tmpl', array('%error%' => $error_msg));
echo $error_msg;
// echo html_footer();

function generatePassword ($length = 8)

// start with a blank password
$password = "";

// define possible characters
$possible = "0123456789bcdfghjkmnpqrstvwxyz";

// set up a counter
$i = 0;

// add random characters to $password until $length is reached
while ($i < $length) {

// pick a random character from the possible ones
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);

// we don't want this character if it's already in the password
if (!strstr($password, $char)) {
$password .= $char;
return $password;

The affiliate ids are not passing. Any ideas why?

10-07-2010, 01:19 AM
Fixed, temporarily. The coding is correct. The affiliate program is being passed to just one product, and I am looking for one that goes to all products. COnsider this solved