I need a php & MySQL script which will do the following:
User presses a button, insert into MySQL table a timestamp, if 60 minutes passed echo a text, if 60 minutes didn’t pass echo another text.
Can any one please help me?
Advertisement
Answer
Even though we shouldn’t do it for you, I will.
JavaScript
x
if(isset($_POST['submit'])){
$timer = mysql_fetch_assoc(mysql_query("SELECT timer FROM table WHERE user='".mysql_real_escape_string($user_id)."');
if((time() <= $timer['timer']) ) {
echo "60mins has not passed";
}else{
mysql_query("UPDATE table SET timer='".strtotime ("+60 seconds")."' WHERE user='".mysql_real_escape_string($user_id)."'");
echo "60mins has passed";
}
}//button pressed