Jump to content

I'm looking for a PHP Referral system for my site


wadboram

Recommended Posts

I want to add a referral system to my membership site that saves cookies.

 

Where the steps go like this:

 

Registration

 

>>

 

Member info. entered in database, and referral link given out like  mysite.com/ref.php?id=xxx

 

>>

 

Page has sql/php coding which then adds +1 in the users referral row.

 

I found this code

 


<?php

include("connect.php"); //make sure we connect to the database first

$user = $_GET['user'];

if(!$user){

//echo out site normally

} else {

$sql = mysql_query("SELECT * FROM members WHERE user='$user' LIMIT 1");

$row = mysql_fetch_array($sql);

$referal = $row['users_referals']; //Get whats in that field

$referaladd = $referal +1; //I am not sure on this as ive not used math operators in php before, but basically your adding one onto whats in the db

$add = mysql_query("UPDATE members SET users_referals = '$referaladd' WHERE user = '$user'"); //Update the db with the users referals

echo "You were refered by $user";

//echo out rest of the site

}

?>

 

Does this help?

Link to comment
Share on other sites

replace this

 

$referaladd = $referal +1; //I am not sure on this as ive not used math operators in php before, but basically your adding one onto whats in the db

$add = mysql_query("UPDATE members SET users_referals = '$referaladd' WHERE user = '$user'"); //Update the db with the users referals

 

with

 

$add = mysql_query("UPDATE members SET users_referals = users_referals+1 WHERE user = '$user'"); //Update the db with the users referals

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.