I'm using this code for one online game called Ragnarok Online. I'm making a script called vote for points, but i want to add a 24 hour time restriction when the user ip matches the ip on database.
My code:
mysql_connect($Host, $User, $Pswd) or die(mysql_error());
mysql_select_db ($Data) or die ("Bla Bla.");
$Vote = mysql_query("SELECT `last_ip` FROM `vote_por_pontos` WHERE `account_id` = '{$Array['account_id']}'");
$Vote_Result = mysql_fetch_assoc($Vote);
$Vote_Time = mysql_query("SELECT `time` FROM `vote_por_pontos` WHERE `account_id` = '{$Array['account_id']}'");
$Vote_Time_Result = mysql_fetch_assoc($Vote);
if($Vote_Result['last_ip'] == "") {
mysql_query("INSERT INTO `vote_por_pontos` (`account_id`, `pontos`, `time`, `last_ip`) VALUES ('{$Array['account_id']}', '1', '".time()."', '$_SERVER[REMOTE_ADDR]')");
echo "Bla bla";
exit;
}
if($Vote_Result['last_ip'] == $_SERVER['REMOTE_ADDR']) {
if($Vote_Time_Result['time'] > (???)) {
}
Field time
returns epoch time.
if($Vote_Result['last_ip'] != $_SERVER['REMOTE_ADDR']) {
mysql_query("UPDATE `vote_por_pontos` SET `pontos` = `pontos` + 1, `last_ip` = '$_SERVER[REMOTE_ADDR]' WHERE `account_id` = '{$Array['account_id']}'");
echo "Bla bla";
exit;
}