Skip to content

Instantly share code, notes, and snippets.

@mskian
Last active May 12, 2017 13:39
Show Gist options
  • Save mskian/82f728e1fb9058423d96df2d49504f26 to your computer and use it in GitHub Desktop.
Save mskian/82f728e1fb9058423d96df2d49504f26 to your computer and use it in GitHub Desktop.
<?php
include("db.php");
$str=mysqli_real_escape_string($con,$_GET["str"]);
//select user
$sql_query="SELECT * FROM referral WHERE str='$str'";
$result_set=mysqli_query($con,$sql_query) or die('error');
$user_ref=mysqli_fetch_array($result_set);
$user=$user_ref['user'];
if(!isset($_COOKIE['referral'])) {
//cookie for visitor
setcookie("referral", $str, time() + (86400 * 7), "/"); // 86400 = 1 day // 86400 * 7 for 7 Days
//page view Counts
$sql = "UPDATE referral SET clicks=clicks+1 WHERE str='$str'";
$result_set=mysqli_query($con,$sql);
}
?>
<?php
if($user_ref == false)
{
echo 'Sorry, the user does not exist.';
}
else
{
?>
<h2>Welcome to Allwebtuts Blog</h2>
<div class="clearfix">&nbsp;</div>
<p><?php echo $user; ?> Loves Allwebtuts what about you??</p>
<p>Read Our Latest Posts</p>
<div class="clearfix">&nbsp;</div>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment