Hi everyone
i am working with Time limitation in php and i am new with time function
i want that i can limit someone action for sometime.
Mean if user login first time he has to post(or some other action) within 24 hours otherwise his account will block.
and when he post his time start again from beginning mean again he got 24 hours for next action.
and i also want to limit just one post in 24 hours …
Please guide me if someone has work with time or know about this
You need a record that expires in 24 hours (246060 seconds). It can be a cookie with expiration = time() + 246060. If cookies are not convenient, you could store the record in a MySQL table or in the file system. Cookies expire automatically. If you use MySQL or the file system you’ll need a CRON-JOBS to periodically clean up the records. I hope that gets you started.
well but i can also save record in database for last login instead of cookie or cron jobs
Moreover i also need some count down script which become compatible with my php code can any one suggest me and describe me
You confuse me.
You say you want someone to take an action -every- 24 hours, but only 1 per 24 hours.
If i make an action at 8 PM, i’ve made my action until 24 hours from then, or 8 PM tomorrow.
But if i dont make my action -exactly- at 8 PM, then i havent made an action in the last 24 hours.
You’re asking your users to thread a needle the size of 1 second.
or are we defining 24 hours as a Day. Which is ENTIRELY different. (Defined as a period from Midnight to Midnight, as opposed to a relative time span)
well my aim is just to restrict people that they can do some action only once in 24 hours if they don’t or do then i can restrict or allow them accordingly… 
hii i found some solution but query not working properly
$que = mysql_query("SELECT TIMESTAMPDIFF(HOUR,mytimestoretable,NOW()) AS 'Diff' FROM table where ID='3075'");
while($row=mysql_fetch_array($que))
{
$re = $row['Diff'];
echo $re;
}
where i am wrong :queasy:
please can someone help to execute proper query through that i can get remaining time ?
please see below and guide me where i am wrong
‘table’ is a reserved word in mySQL. If you’ve actually named your table ‘table’, you’ll need to put backticks (`) around it so that the server knows to handle it as a label and not the reserved word. But i’d change the table name, if it were me.
Well thanks for your suggestion well the problem was with my database connection. But the second thing I want some count down script or good code in which I can adjust my php variable for showing remaining time to users. I have seen many scripts but all are in java or Jquery can you suggest me any one with little details that how to adjust my variable with that . Thanks
Anything that does this will be written in a Browser-Side code. Javascript/JQuery, Flash, something of the like. PHP cannot (by itself) have an updating count-down script. PHP code runs at the server level during Interpretation time.
Please suggest me some easy count down easy to editable and adjustable with my php code
Hi guys I am little confuse in structure of my database and php code.
Infact as I have already mentioned above that I want to restrict user that after his first sign up
He must need to submit post within 24 hours
Second If he don’t post in 24 hours after checking parameters we provide him extra 48 Hours for posting.
And if he post in first 24 hours or in extra 48 hours one more limitation I want to apply that
User can only post once in 24 hours if he has post once for example if he has 24 hours and he has post in first 12 hours than he will not be able to post in next 12 hours,
Once again reviewing my point below
After first sign up user has to post in 24 hours
If he don’t post he will get extra 48 hours
User only post once in 24 hours.
Please suggest me your ideas about database structure and php Code.
Thanks
how can i get latest record from any table against specific clue
for example want to fetch time against userid=3 but i want that only latest record show me?
what i use in mysql query?
There is probably more than one way to do it. I would use
$sql = SELECT login
FROM table
WHERE userid = '$userid'
SORT login DESCENDING
LIMIT 1;
where login is the date and time the user last logged in
LIMIT 1 gets just one record
SORT login DESCENDING puts the latest date on top
so you should get the last time the user logged in.
HI guys
i am having one more question here i have create 24 Hours Post system. that users must post within 24 hours from his last post time otherwise he will be block. but thing more here i need your ideas as i have already describes in my above mails that if users has 24 hours and he has posted his first post in first 12 hours. then he can’t post next in 12 hours till when his 24 hours don’t complete.
below is my code with which i am already working please suggest me how to add this restriction
$que = mysql_query("SELECT TIMESTAMPDIFF(SECOND,time,NOW()) AS 'Diff' FROM link where userid='1' order by time desc limit 1");
while($row=mysql_fetch_array($que))
{
$re = $row['Diff'];
$hour = "86200";
$diff = $hour - $re ;
if($diff <= 0)
{
echo "Your time has been over please contact your administrator";
exit;
}
else i showed him posting material }
?>
infact I want that if user has 24 hours for posting and he has posted in first 15 hours he can’t post in next 9 hour. Mean before completing 24 hours he can’t post his next post. After 24 hour than he can have the option of posting with more 24 hours.
Please help on above query any wayi can save difference or any cookie or any other way where i can save difference . Please help