JayC
Well-Known Member
I have been trying this for hours. I am not very good with timestamps/dates and I really need a refresher. I tried looking at tutorials before posting and tried so hard to figure it out myself but I need a little help Thanks Guys. Heres what I got:
When the button is clicked it updates the users information:
$newTimeStamp = time(); <-- Gets the current time ON THE SERVER
mysql_query("UPDATE user_lottery SET Rolled = '". $newTimeStamp ."' WHERE user_id = '". $_SESSION['user']['id'] ."'");
Then it updates the users entry with that time (Which this part works fine)
So after it gets the time I want to test if its been 24 hours PAST that timestamp.
$checkdatabase = mysql_query("SELECT Rolled FROM user_lottery WHERE user_id = '". $_SESSION['user']['id'] ."'");
So this line above, grabs the Rolled column from user_lottery
if(strtotime($checkdatabase) > strtotime("-24 hours"))
Then this line says if that time is greater then that - 24 hours then do this...
{
But when I update my database manually, and refresh the page EVEN if I make the date smaller, bigger or the same , my code of the button does not show. So here is the whole code:
<?php
$checkdatabase = mysql_query("SELECT Rolled FROM user_lottery WHERE user_id = '". $_SESSION['user']['id'] ."'");
if(strtotime($checkdatabase) > strtotime("-24 hours"))
{
?>
<form method="post">
<input type="submit" value="Free Roll" name="getValues" class="submit"/>
</form>
<?php
}else{
?>
You have already rolled your free roll
<?php
}
?>
When the button is clicked it updates the users information:
$newTimeStamp = time(); <-- Gets the current time ON THE SERVER
mysql_query("UPDATE user_lottery SET Rolled = '". $newTimeStamp ."' WHERE user_id = '". $_SESSION['user']['id'] ."'");
Then it updates the users entry with that time (Which this part works fine)
So after it gets the time I want to test if its been 24 hours PAST that timestamp.
$checkdatabase = mysql_query("SELECT Rolled FROM user_lottery WHERE user_id = '". $_SESSION['user']['id'] ."'");
So this line above, grabs the Rolled column from user_lottery
if(strtotime($checkdatabase) > strtotime("-24 hours"))
Then this line says if that time is greater then that - 24 hours then do this...
{
But when I update my database manually, and refresh the page EVEN if I make the date smaller, bigger or the same , my code of the button does not show. So here is the whole code:
<?php
$checkdatabase = mysql_query("SELECT Rolled FROM user_lottery WHERE user_id = '". $_SESSION['user']['id'] ."'");
if(strtotime($checkdatabase) > strtotime("-24 hours"))
{
?>
<form method="post">
<input type="submit" value="Free Roll" name="getValues" class="submit"/>
</form>
<?php
}else{
?>
You have already rolled your free roll
<?php
}
?>