Hi guys
Can anyone point me in the direction of a tutorial or some such material on using a timestamp against a user login
Basically I have a registration script which picks up the date a user registers. I want to take that info and allow access for a set time before they have to pay to use the site say 14 days now im sure I can fix it to just take the date and add say 14 days to it before denying access but is it as simple as writing if statements to get the code to recognise when the month changes, or is it better to do this in the SQL ?
Thanks in advance
Restricting a login based on timestamps
Moderator: General Moderators
- evilchris2003
- Forum Contributor
- Posts: 106
- Joined: Sun Nov 12, 2006 6:43 am
- Location: Derby, UK
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Restricting a login based on timestamps
Create another datetime field, and call it something like 'expirydate', each time they make a payment increment this field by x amount of days,
Then simply check if
to see if the the user is valid
Code: Select all
UPDATE users SET expirydate = ADDDATE(NOW(), INTERVAL 14 DAY) WHERE id=$useridCode: Select all
SELECT * FROM users` WHERE expirydate < NOW() AND id = $userid- evilchris2003
- Forum Contributor
- Posts: 106
- Joined: Sun Nov 12, 2006 6:43 am
- Location: Derby, UK
Re: Restricting a login based on timestamps
Thanks Jcart
thought there would be a simple way of doing it
thought there would be a simple way of doing it