...

View Full Version : How to have a content unlock within certain period of time...



Eric Leon
04-23-2012, 11:34 PM
I have this website that when people register, and everyday there's a new video.

Anyways, I was wondering how I could make it so that a certain video unlock on a daily basis for a member? Now, keep in mind that everyone registers at different times, so..

Example:

If "Bob" registers on April 2, the first day he gets Video one, then April 3rd, he gets Video two.

And at the same time, let's say "Bill" registers on April 5th, I want Bill to start off with video one then on April 6th, have video two automatically unlocked for him. I don't want Bill to start off with Video four when he first registers because Bob registered 4 days before.

myfayt
04-24-2012, 01:26 AM
setup fields in a database and a date/time field.

Registered put in NOW(), then have a cron job or just a login script insert to update the date difference.

Eric Leon
04-24-2012, 01:28 AM
I'm a coding newbie...would it be possible if you could be specific or find a guide on how it tells me to complete this task? If not, I understand.

myfayt
04-24-2012, 02:33 AM
How do you want to set it up for the next video to be unlocked? if you register May 1st, and login again on May 4th you have 4 videos unlocked? Or do you want the person to be active every day to get a video? Lots of options.

Eric Leon
04-24-2012, 02:55 AM
How do you want to set it up for the next video to be unlocked? if you register May 1st, and login again on May 4th you have 4 videos unlocked? Or do you want the person to be active every day to get a video? Lots of options.

Second one but, only to log in ONCE after the 24 hours.

Example:

May 1 at 5 PM, they register - First video unlocked
Inactive until May 4th of 4:54 PM - Second video unlocks

HOWEVER...

If:

May 1 at 5 PM, they register - First video unlocked
May 2 at 4:54 PM, they log in...they have to wait 6 more minutes until video 2 shows.

Regardless of the situation...they only need to log in ONCE for the video to show up. Meaning, even if they log in for a second and log out, if the appropriate time as passed, I want the next video to show.

myfayt
04-24-2012, 05:56 PM
Add a field in your database called "lastlogin" and another "videonumber".
Make the lastlogin a DATETIME, and the videonumber just a tinyint(3).

Have a default of 0 for videonumber.

Do a check when they login such as: if ($user['videonumber'] == 0) {
echo "This is your first time logging in, you've unlocked your first video!";

Do a query to add a number to the videonumber field such as SET videonumber=videonumber+1

You need a PHP code to check date/time difference. When they login, have it check for a 24 hour between lastlogin field and current time (I am not good with date/time codes). If the difference is greater than 24 hours, do another query and do videonumber=videonumber+1

Setup your videos to be displayed if that number is reached. Such as a loop, foreach or a static number. Such as: if ($user['videonumber'] == 5) { //SHOW VIDEO

I am not sure how you wish to set it up.

I hope this is helpful. :thumbsup:

Eric Leon
04-26-2012, 04:49 AM
Understood some parts. Can someone be anymore specific?

myfayt
04-26-2012, 05:46 PM
Well which parts don't make sense and I can explain them a bit better?

loopsnhoops
04-26-2012, 06:51 PM
You do know SQL right? myfayts advice is sound



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum