MSK PHP Referral System – Create Simple user Referral System for blog


MSK PHP Referral System

MSK PHP Referral System – Simple user Referral System for Blogs

MSK PHP Referral System

Create your Own Referral System for your Blog Which Helps us to Promote our Latest Blog post, popular posts, and Ebooks.

Mostly We having Referral System System for App and Product promotions.We can also Promote our Blog VIA Referral System 😛

How to Promote the Blog/pages/post promote Via Referral System?

Ok, it’s Time to Explain but I did not know how it has gone to Work.

Install our MSK PHP Referral System Plugin and Create a Welcome page for the user’s who visit your blog/website from Via Referral URL

On that Page Add an Info about your Blogs or add your Blogs Popular Stuffs also you can easily promote your E-books by this Method 🙂

Create an URL for the Website/Blog Owners who are all going to promote your blog/website through Banners/Site-wide links.

it will count the Referral URL’s Clicks you can Set some count points & reward the promoters.

Our Plugin having Cookies for Accurate Click Counts 🙂

Features in MSK PHP Referral System

Platform Used

  • PHP
  • MYSQL
  • PHP Cookies

Requirments

  • PHP/MYSQL Supported Hosting Platform
  • PHP 5.6 or PHP7
  • MYSQL or MariaDB

How to Install and Use the MSK PHP Referral System?

First We Need to Create 8 PHP files for this Plugin

File Structure

MSK PHP Referral System

Plugin Setup and Installation

  • First Create a Folder for this Plugin Named as “refer
  • After that Create a Database table for the plugin to store users data
  • Run this Below query on Database to create tables
CREATE TABLE referral
(
 id INT NOT NULL AUTO_INCREMENT,
 user VARCHAR (500) NOT NULL UNIQUE, 
 str VARCHAR (500) NOT NULL UNIQUE,
 clicks INT NOT NULL DEFAULT '0',
PRIMARY KEY (ID)
);

Table Output

MSK PHP Referral System

  • db.php – Database Connection
<?php

session_start();
error_reporting(0);

$dbhost = 'localhost';
$dbuser = 'YOUR DB USER';
$dbpass = 'YOUR DB PASS';
$dbname = 'YOUR DB NAME';

$con=mysqli_connect($dbhost, $dbuser, $dbpass,$dbname) //connect to the database server
or die ("Could not connect to mysql because ".mysqli_error());

mysqli_select_db($con,$dbname) //select the database
or die ("Could not select to mysql because ".mysqli_error());

//Admin User Credits
$admin_username = 'YOUR USERNAME';
$admin_password = 'YOUR PASSWORD';

?>
  • Replace YOUR DB USERYOUR DB PASSYOUR DB NAME with Database Login Credits
  • Replace YOUR USERNAME, YOUR PASSWORD  with your Username and password this one for Admin Login
  • login.php – Login Protection for Referral Generator Page
<?php


include('db.php');


if(isset($_SESSION['loggedin'])) {
header('location:index.php');
}

if($_POST)
{
$data = $_POST;
if( ($data['username'] == $admin_username) && ($data['password'] == $admin_password) )
{
$_SESSION['loggedin'] = 'Yes';
header('location:index.php');
}
}


$message = 'Invalid Account Details!';
 
?>

<?php
if(isset($_POST['username'])) {
echo $message;
}
?>


<h2>MSK PHP Referral System</h2>
<div class="clearfix">&nbsp;</div>
<form method="post">
<input type="text" name="username" placeholder="Username">
<br />
<input type="password" class="form-control" name="password" placeholder="password">
<button type="submit">Let me login</button>
</form>

Login Page Output

MSK PHP Referral System

  • logincheck.php – Session for Login Page
<?php
if(!isset($_SESSION['loggedin']))
{
header("location:login.php");
}
?>
  • logout.php
<?php
session_start();
$_SESSION['loggedin'] = false;
session_destroy();
header("location:index.php");
?>
  • index.php – Create Referral URL

  • Replace http://localhost/refer/ With your URL

Referral Admin page Output

MSK PHP Referral System

  • welcome.php – Welcome page for users came from Referral URL

Welcome Page Output

MSK PHP Referral System

  • status.php – Check the user referral Click Counts by ID value

Status Page Output

MSK PHP Referral System

Check User refer Status

http://example.com/refer/status.php?id=1
  • HTACCESS  for SEO Friendly URL (http://example.com/refer/allwebtuts)
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ welcome.php?str=$1

 

Database

All the user’s Details are Stored on Database

MSK PHP Referral System

Cookies

PHP Cookies For Genuine Click Counts

W3schools – Learn More About PHP Cookies

MSK PHP Referral System

Modify Cookies

you can Find this Below line on the welcome.php file

//cookie for visitor
setcookie("referral", $str, time() + (86400 * 7), "/"); // 86400 = 1 day // 86400 * 7 for 7 Days
  • referral – Cookie Name
  • $str – Cookie Content

Set your Own Cookie Times & Conditions

Download Plugin File

Tutorial File


Security

For a demo, I Display the Login page in Main Folder.For Better security Move the Admin Page to Separate Folder or Create a folder for admin on Plugin Folder.Download My Sample Setup’s


PS: This Plugin Package contains Demo Front-end Design Only.Cook your Frond-End as Per your Taste 🙂

From the Editor’s Desk

Hope this tutorial Will Helps you to Create a Referral System for your websites and Blogs.

If you Have Any Doubts in this Topic Just Drop your Comments Here I will Guide you.

Stay Join With us for Upcoming Plugin Updates 🙂

Share is Caring Forward this post to your Blogging Circles.

Our Free PHP Plugins

 


Was this article helpful?
Thanks!

Your feedback helps us improve Allwebtuts.com



23 Shares
+12
Tweet
Share19
Pin1
Stumble1