This topic is locked
[SOLVED]

 Login Between time frame or Disable add not in time frame

11/13/2013 09:19:19
PHPRunner General questions
M
maaroufkamel author

Hi !
i have a table with the following
Date_Time is the record date and automatically date generated by now() when a user add a new record
i need an event
1- "before add" that the user can only add records between time frame from 6:00PM to 11:00PM and if he tried to add in other times display message and not saving the record
2- or disable add button if the user login in times not in the time frame.
Thanks in advance to all ,

Graphix 11/13/2013

Hi

I am very new at PHP so will try and help best I can LOL

I have bought a teach yourself PHP book and if I am understanding your question you could add this code or something formatted for PHPrunner better than I have done here like this in before record added,
use H from date - 24-hour format of an hour:
if( (date('H') >= 18) && (date('H') < 23) ){

// between 6:00PM and 11:00PM

return true;

else

$message = "You cannot add data at this time";

return false;

}
like i said I am still learning myself but logic says im on the right track lol

regards

Kevan <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=72841&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />

Sergey Kornilov admin 11/13/2013

Just wanted to say that Kevan's idea will work. I would just suggest to move this code to Add page BeforeProcess event and modify it a bit.

if( (date('H') < 18) && (date('H') >= 23) ){

echo "You cannot add data at this time";

exit();

}


This way user don't have to enter any data on the Add page just find her effort was wasted.

M
maaroufkamel author 12/4/2013

thank you very much Kaven , it works !!!