The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do you make a referral system on US?
#1
How would you allow users to make their referral link and when a unique ip accesses that and signs up the user of the referral link receives +1 in their payout column in the database.
  Reply
#2
Well...Hmm. Let's work on this. This is kind of a basic overview of how I would walk through that logic to get you started

There is a tool in userspice called Input::get which will probably be your friend here.

What if you made a page called refer.php

Have that page look for the referrer's username in the link. So let's say my link looked like...

https://userspice.com/refer.php?id=mudmin

Then maybe you would add 2 columns to the users table.
Code:
payouts
and
Code:
payouts_paid

refer.php would look something like this...

Code:
$refer = Input::get('id'); //id is the get variable in the link

Then you want to check the database to see if that variable is legit.

Code:
$legitQ = $db->query("SELECT * FROM users WHERE username = ?",array($refer);
//check all usersnames for that link
Code:
$legitC = $legitQ->count();
//how many results did you get

Code:
if($legitC < 1){
Code:
echo "Invalid referral link.";
Code:
}else{
//get the user's account
$
Code:
legit = $legitQ->first();
//since usernames are unique, you only need first()
$oldPayout = $legit->payouts; //how many payouts DID they have
Code:
$newPayout = $oldPayout + 1;
Code:
$db->update("users",$legit->id,'payouts'=>$newPayout);
//give the user credit
//do whatever else you want to do
Code:
}
  Reply
#3
ok thank you very much!
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)