Jump to content

How to have msql connect just in some preset time intervals?


Recommended Posts

I'm doing my own project for my own website, and I want to run a sports handicapping contest.

 

I have this problem to solve:

 

I would need that participants to be able to input data in the database just in some preset time intervals.

These would be between 11 AM EST -18.30 PM EST on weekdays (Monday-Friday)

and between 8.30 AM EST - 11.30 EST on weekends (Saturday - Sunday).

It's very important that these times must be is EST (New York's time).

 

There is any solution to this?

Something applying the if, else and elseif statements?

I'm hosted on Linux server.

 

Thanks in advance!  :)

Then only make you page available during these dates.. .this isn't a mysql issue.

 

I can't do that, because every contestant has a separate input page (accessible with username and password) and a separate output page from the DB.

 

And anyways how to make a page available only during some times, if I'm not accessing the page to make it go off-line (how something like you said could be automated?)

A separate input page -- you mean like with htaccess?  That must be PITA to maintain.

 

I was simply assuming you had some php code checking credentials.

 

It's not PITA to maintan, because only needs to be given once at any contestant (and the number is limited to 50). All these pages are the same, only the database name + contestant's name differs in all of them. After I setup 1 person, there is no maintenance at all. And the same goes for the output pages.

Takes 3 minutes to setup 1 person...

Though I'm thinking now that if one single page can be blocked between some time limits than nobody can input sport picks, because that page contains all the possible choices.

 

But I was looking all over the place, and I can't find any script that would do that: to be automated and able to be set to some times, and also would not block based on IP, but all users!

couldn't you:

1) get current date/time

2) check if it is within your valid time range

3) if yes, display page, if not don't?

 

How can that be done?

With PHP or Javascript? I have no idea. And to do that you need to be probably advanced in these languages, and I'm not.

But all this solution to block this page is just some kind of half solution, because nothing prevents anyone to look at the page in the time when it's up, but then make his inputs a long time after the page is hidden- which in my case means he can input well after the games begun, or even ended, cheating this  way the system (= cheating the contest itself).

 

So really the real solution is just to block all the input pages between the wanted time intervals.

 

If this can't be solved, than it's a big PITA, because everything needs to be totally re-thought and redesigned just because of this detail.

Maybe this could be done just with some sort of programming resembling to what only sportsbooks have, and all those are multi-thousand $ softwares.  :-\

 

__________________

 

Since there were so many views for this thread, but no solution given it looks that's impossible to make msql to connect just in some preset time intervals.  >:(

Something like this at the very top of your page with the form.  I didn't spend a lot of time on it, but I believe it will do basically what you want...

<?php
//these are set to the current server time...if your server is in
//a different time zone, these need to be adjusted accordingly
$weekday_times=array("open_time"=>1100, "close_time"=>1830);  //set in 24 hour format
$weekend_times=array("open_time"=>830, "close_time"=>1130);
$closed_message = "We are currently closed.";

$cur_day = date("N");  				//current day of week: 1=mon, 7=sun
$cur_time = date("G") . date("i");  //current hour/minute in 24 hour format

if($cur_day < 6){ //check weekdays
if($cur_time < $weekday_times['open_time'] || $cur_time > $weekday_times['close_time']) die($closed_message);
} else {  //check weekends
if($cur_time < $weekend_times['open_time'] || $cur_time > $weekend_times['close_time']) die($closed_message);
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.