mysty Posted February 14, 2007 Share Posted February 14, 2007 I have a site that has a database for user’s information. I would like to control how many days each user has access to the site. That is, when a user registers, he has access to the site for 10 days. Can I control that using MySQL or would I use PHP code or ?? Quote Link to comment https://forums.phpfreaks.com/topic/38523-how-can-i-control-how-many-days-a-user-uses-my-site/ Share on other sites More sharing options...
fenway Posted February 14, 2007 Share Posted February 14, 2007 Sure... add an expiry column to the users table, and check that on login. Quote Link to comment https://forums.phpfreaks.com/topic/38523-how-can-i-control-how-many-days-a-user-uses-my-site/#findComment-184893 Share on other sites More sharing options...
mysty Posted February 14, 2007 Author Share Posted February 14, 2007 So, are you saying I should make 2 new columns - a TimeStamp to put the registration date into the database and one for Datetime as the expiry field? I would like to have the user register and fill in a field in the registration form that tells how many days he has on the site. How would I then check the 2 new columns? Quote Link to comment https://forums.phpfreaks.com/topic/38523-how-can-i-control-how-many-days-a-user-uses-my-site/#findComment-184942 Share on other sites More sharing options...
artacus Posted February 15, 2007 Share Posted February 15, 2007 You don't NEED two columns. But using the two column approach allows you to extend a person's 10 day period easier. Say if you wanted to make an exception because a users' brother died 2 days after she registered. But to do it with the one column approach, you would add something like this to the where clause: AND NOW() BETWEEN registeredOn AND DATE_ADD(registeredOn, INTERVAL 10 DAY) Quote Link to comment https://forums.phpfreaks.com/topic/38523-how-can-i-control-how-many-days-a-user-uses-my-site/#findComment-185105 Share on other sites More sharing options...
fenway Posted February 15, 2007 Share Posted February 15, 2007 Always use two columns... registration_date and expriy_date, both datetime types. Quote Link to comment https://forums.phpfreaks.com/topic/38523-how-can-i-control-how-many-days-a-user-uses-my-site/#findComment-185568 Share on other sites More sharing options...
mysty Posted February 15, 2007 Author Share Posted February 15, 2007 When a person registers, I can fill the reg_date column, but how would I fill the expiry_date column? That is, I would want the expiry_date to show registration date plus 10 days. Not sure how to do that? Quote Link to comment https://forums.phpfreaks.com/topic/38523-how-can-i-control-how-many-days-a-user-uses-my-site/#findComment-185696 Share on other sites More sharing options...
fenway Posted February 15, 2007 Share Posted February 15, 2007 Use NOW() + INTERVAL 10 DAY. Quote Link to comment https://forums.phpfreaks.com/topic/38523-how-can-i-control-how-many-days-a-user-uses-my-site/#findComment-185811 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.