Crew-Portal Posted August 5, 2007 Share Posted August 5, 2007 Hi I am creating a Virtual Airline Manager (For Flight Simulator). My problem is that i only want a member to be allowed to post a flight and then it locks the page for 1 hour so that they cannot post multiple flights. How would I go about locking the Insert into * functions and just displaying something like: You may not Post another flight. You may post again in $time. Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/ Share on other sites More sharing options...
dbo Posted August 5, 2007 Share Posted August 5, 2007 Erm, the script doesn't run for an hour though does it? Cause if it does that'll give you other issues to deal with. But what I'd do is create some sort of boolean field that's stored in a database that says... is the page locked or not. Then display the appropriate message/take action. Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315905 Share on other sites More sharing options...
phpQuestioner Posted August 5, 2007 Share Posted August 5, 2007 You could setcookie for one hour to prevent member from accessing the part of your code where your mysql_query is. Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315906 Share on other sites More sharing options...
Fadion Posted August 5, 2007 Share Posted August 5, 2007 When the user posts the flight, u can insert in a specific column (maybe in the users table in a column like lastPost) the actual date and time. When he tries to post another flight, compare the database time with the actual date and time and if it is more then one hour let him post. When he posts again, override the old date so the process starts all over. Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315908 Share on other sites More sharing options...
dbo Posted August 5, 2007 Share Posted August 5, 2007 Yes you could but if cookies are disabled or it's a different user who doesn't have that cookie set they could still run the code and screw it up. Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315909 Share on other sites More sharing options...
dbo Posted August 5, 2007 Share Posted August 5, 2007 Yeah in the db you'll want to have a timestamp in some capacity or another to know when to release the lock. Good call GG. Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315911 Share on other sites More sharing options...
Crew-Portal Posted August 5, 2007 Author Share Posted August 5, 2007 Would it be possible to save the IP and time it was accessed in a PHP Query and only allow it to run when the time is equal to or less than the colums time? Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315912 Share on other sites More sharing options...
Fadion Posted August 5, 2007 Share Posted August 5, 2007 Yep cookies may be disabled, one user may access the script in a different pc or one can just delete them. Edit: Thnx dbo Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315914 Share on other sites More sharing options...
Fadion Posted August 5, 2007 Share Posted August 5, 2007 U can get the IP without any problems but what do u need for? If u have logged users then u just need that column in the db and a simple time compare. Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315918 Share on other sites More sharing options...
phpQuestioner Posted August 5, 2007 Share Posted August 5, 2007 <?php // Insert date("G") into database field // Pull this variable from database $dbfieldtimevar = $row["postTime"]; $allowentrance = $dbfieldtimevar + 1; $currenthour = date("G"); if ($currenthour >= $allowentrance) { // allow user to access mysql_query } else { echo "Hey I Know You!"; exit; } ?> Or something like this - maybe...... Might have to tweak it a bit for 12:AM though Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315925 Share on other sites More sharing options...
Crew-Portal Posted August 5, 2007 Author Share Posted August 5, 2007 Hum... Thanks Ill Try That! Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315926 Share on other sites More sharing options...
Crew-Portal Posted August 5, 2007 Author Share Posted August 5, 2007 Looks Good! Thanks Just gotta tune it into what I need! Thanks Again TOPIC SOLVED!!! (I Love Saying That?!) Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315927 Share on other sites More sharing options...
phpQuestioner Posted August 5, 2007 Share Posted August 5, 2007 You may need to set the current date that person submits query and combine a similar code to the hour check code I provided; that way you check date and time person submitted query. This will check for a false positive on the time and day. Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315929 Share on other sites More sharing options...
Crew-Portal Posted August 5, 2007 Author Share Posted August 5, 2007 Ya Thanks! PS: 90th POST Yippee!!! Quote Link to comment https://forums.phpfreaks.com/topic/63377-solved-post-timer/#findComment-315932 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.