In building a Script to Rate Articles writen by users , i dont want a user to be able to rate an article except 1 time every 24 hours ...
So this code , gets the last rating a user submitted , and gets the timestamp , and compares it using mktime to the time 24 hours ago ... If it's been less then 24 hours , the header is supposed to forward them to a page and exit , if its been more then 24 hours , The rating will go thru , but that code isnt listed.
This code below is simply supposed to check to see if it has been 24 hours since a user rated an article , if not , then forward them to another page
it's not working tho ... its still allowing ratings to go thru ....
if someone could look this over and let me know if you see anything wrong , thanks
## Get Rating Information About User From MYSQL
$sql = "SELECT `rater`, `time` FROM `shocc_ratings` WHERE `ratee` = '$ratee' AND `rater` = '$sess_user' ORDER BY `time` DESC LIMIT 0,1";
$query = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($query)) {
$last_rated = @mysql_result($query, "0", "time");
} else {
$last_rated ="";
}
$yesterday = date("YmdHis",
mktime(date("H"), date("i"), date("s"), date("m"), date("d")-1, date("Y")));
$too_soon = false;
if($last_rated > $yesterday) $too_soon = true;
if($too_soon){
header("Location: /profile.php?u=$ratee&rate=0");
exit;
}