When they vote , they get redirected to a secret page, which redirects them back to client. On the secret page just few lines of code:
<?php
$amount = 5000;
$lastTime = mysql_fetch_assoc(mysql_query("SELECT lastGiven FROM user_rewards WHERE username='".$_SESSION['user']['username']."'"));
if(mysql_num_rows($lastTime) < 1){
mysql_query("INSERT INTO user_rewards (lastGiven, username) VALUES ('".time()."', '".$_SESSION['user']['username']."')");
mysql_query("UPDATE users SET `credits` = (`credits` + '".$amount."') WHERE username='".$_SESSION['user']['username']."'");
mysql_query("UPDATE user_rewards SET lastGiven = '".time()."' WHERE username='".$_SESSION['user']['username']."'");
}
if((date(H, $lastTime) - time()) > 23){
mysql_query("UPDATE users SET `credits` = (`credits` + '".$amount."') WHERE username='".$_SESSION['user']['username']."'");
mysql_query("UPDATE user_rewards SET lastGiven = '".time()."' WHERE username='".$_SESSION['user']['username']."'");
}
header(Location: "/client");
?>
When they vote , they get redirected to a secret page, which redirects them back to client. On the secret page just few lines of code:
And Create This Table:PHP:<?php $amount = 5000; $lastTime = mysql_fetch_assoc(mysql_query("SELECT lastGiven FROM user_rewards WHERE username='".$_SESSION['user']['username']."'")); if(mysql_num_rows($lastTime) < 1){ mysql_query("INSERT INTO user_rewards (lastGiven, username) VALUES ('".time()."', '".$_SESSION['user']['username']."')"); mysql_query("UPDATE users SET `credits` = (`credits` + '".$amount."') WHERE username='".$_SESSION['user']['username']."'"); mysql_query("UPDATE user_rewards SET lastGiven = '".time()."' WHERE username='".$_SESSION['user']['username']."'"); } if((date(H, $lastTime) - time()) > 23){ mysql_query("UPDATE users SET `credits` = (`credits` + '".$amount."') WHERE username='".$_SESSION['user']['username']."'"); mysql_query("UPDATE user_rewards SET lastGiven = '".time()."' WHERE username='".$_SESSION['user']['username']."'"); } header(Location: "/client"); ?>
user_rewards
lastGiven -> Timestamp (Length 0 , Decimal 0)
username -> Varchar (Length 50, Decimal 0)
Okay. Rest is up to you ! This is just something I coded real fast.
if((date('H', $lastTime) - time()) > 23){White screen.
If it is white screen then the problem is with the code not the sql's.Are you able to put the sql in for me I think I did it wrong causing the page not to work.