Jump to content

Disabling a user's ability to submit a form based on the date


sws

Recommended Posts

Hi,

I have created a sports pool in which the user uses a form to make a bunch of player selections. When they submit the form their picks are entered into my database.  I'm now trying to take it to the next step.

Currently, the form can be filled out over and over again but I want it so that the user must submit picks each week by Sunday night 11:59 pm (Pacific time). Once they've submitted their picks for the week, they can not change their picks for the week. After 11:59 pm each Sunday night, I want the form to be disabled.

The form will then be enabled again each Saturday from 11:59 PST to Sunday night 11:59 pst for user's to enter their picks for the upcoming week.

Any suggestions on how to accomplish this ?

Link to comment
Share on other sites

First off, I'm going to assume your users have a UserID.  I'm also going to assume the possible selections also have an ID, I'll call it PickID.  I would use a table structure like this:

table: [b]PickTrack[/b]
TrackID INT AUTO INC etc
UserID INT
EnterTime DATETIME

table: [b]PickTrackItems[/b]
TrackID INT
PickID INT
UNIQUE(TrackID, PickID)

When a user makes their selections, you make a single entry in [b]PickTrack[/b] with the times that the selection was made.  You then enter all of the selected picks into [b]PickTrackItems[/b] and attach them to the single entry from the previous table.

When a user visits this page, you can calculate the timestamp of the exact cutoff date for this week as well as one week ago.  If no entry in [b]PickTrack[/b] between those dates exists for the user you can display the form.
Link to comment
Share on other sites

Thanks. Sounds like a good solution.

I am using a user id and a pick id (which is basically the player id for each player... tied back to the players table). I'm plugging this all into just one managers table right now though. Then on the page that displays the standings I pull the data from the managers and players table and display it.

I'll break it up into two tables: a picktrack table and a picktrackitems table.

Does this mean that my managers table will just contain the username and the unique id ?  So essentially I'll have 3 tables ?

I have to plan ahead for when I add other pools. The manager will be allowed to enter several different pools but can only enter each pool once.
Link to comment
Share on other sites

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.