Jump to content

Problems with a simple referral system


Sigurd

Recommended Posts

Greetings,

I am willing to add a simple referral system to a exchange script I've downloaded. The aim is to the user give his link like site.com/index.php?ref=123 and by the moment someone click his link it generates a cookie, when they register he gets 500 credits.

I tried splitting into 2 files and using include, but it wont credit.

The two pieces of script I have to do that are

 

the cookies:

 

<?PHP

 

$ref = ($_GET['ref']);

setcookie ('referred-user', $ref, time()+36000);

 

?>

 

and the credits insertion into database:

 

<?PHP

 

mysql_connect('localhost', 'root', '')

        or die ("Database CONNECT Error (line 32)");

 

$ref = $_COOKIE['referred-user'];

 

dq("update banex set i_earned = i_earned + 500 where number = '$ref'",1);

 

?>

 

"number" is a unique auto inc id wich I used in here to refer to the referrer.

 

I do not have a register page and register successful page separated, they are all bounded into one single index, which contains the templates in html.

index is this one:

 

<?PHP

 

include('./functions.php'); if (!$_POST) page_from_template('join.html',$s);

include('./ref.php');

$in = $_POST;

if ((!$in[urlbanner]) OR (!$in[username]) OR (!$in[password]) OR (!$in) OR (!$in[siteurl])) public_problem('All fields are required. Please try again.');

if (!eregi("^[a-z0-9]{5,15}$",$in[username])) public_problem('Incorrect username. It should contain only letters and numbers and have 5-15 characters.');

if (!eregi("^[a-z0-9]{5,15}$",$in[password])) public_problem('Incorrect password. It should contain only letters and numbers and have 5-15 characters.');

if (strlen($in) > 255) public_problem('Email address is too long. Maximum is 255 characters.');

if (strlen($in[siteurl]) > 255) public_problem ('URL is too long. Maximum is 255 characters.');

if (strlen($in[urlbanner]) > 255) public_problem ('Banner URL is too long. Maximum is 255 characters.');

if (!check_email($in)) public_problem ('Wrong email address. Please try again.');

if (!eregi("http://*",$in[siteurl])) public_problem ('Wrong URL. Please try again.');

$q = dq("select count(*) from $s[tblname] where username = '$in[username]'",0); $data = mysql_fetch_row($q); if ($data[0]) public_problem('Entered username is already in use. Please use another.');

eregi(".*gif$",$in[urlbanner],$hh); eregi(".*jpg$",$in[urlbanner],$hh); eregi(".*png$",$in[urlbanner],$hh); if (!$hh[0]) public_problem ('Incorrect banner image format. Please try again.');

$cas = time(); $datum = Date('Y-m-d');

dq("insert into $s[tblname] values('$in[username]','$in[password]','$in','$in[siteurl]','$in[urlbanner]','0','0','0','$datum','$cas','0','0',NULL)",1);

include('./referral.php');

$in[number] = mysql_insert_id();

$in[memberfile] = "$s[phpdirectory]/member.php"; $in[to] = $in; mail_from_template('email_join.txt',$in);

$in[adminfile] = "$s[phpdirectory]/admin/"; $in[memberemail] = $in; $in[to] = $s; mail_from_template('email_admin.txt',$in);

$s[workfile]="$s[phpdirectory]/work.php?ID=$in[username]"; $in = parse_part('html.txt',$s);

$a[memberfile]="$s[phpdirectory]/member.php"; $in[banner] = '<img border=0 width="'.$s[width].'" height="'.$s[height].'" src="'.$in[urlbanner].'">'; page_from_template('join_success.html',$in);

#########################################################################

 

?>

 

And than, would be handy if you could give me a script piece which shows users their referral link =$

 

I mostly appreciate it

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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