laron Posted April 26, 2007 Share Posted April 26, 2007 i'm not sure how to do this. ive created a database and when a member signs up there member data is created in the database with there status as "0" but as soon as they pay it changes to "1" being a valid member. now my problem is that when they become a member, they are paying for a 1 year membership. how can i set there status back to "0"(or another #) after one year if not renewed? what im thinking is creating a "date_registered" field which will be set when they sign up, and a "date_expire" field which will be checked against everytime they log in. if the date now, is greater than the "date_expire" for there account, there status will be set back to "0" or another number meaning they were a member and all they have to do is renew there membership to access the members page once again. my question is what type of variable do i store the date as, in the database, and what do i use to set the date they registered, and date it will expire? the date() function or ??. anyway hope you can understand what im saying and help if possible. Link to comment https://forums.phpfreaks.com/topic/48850-restrict-users-after-certain-amount-of-time/ Share on other sites More sharing options...
Caesar Posted April 26, 2007 Share Posted April 26, 2007 Store all the dates as timestamps. And check the registration date on each login. Should be simple enough. Link to comment https://forums.phpfreaks.com/topic/48850-restrict-users-after-certain-amount-of-time/#findComment-239460 Share on other sites More sharing options...
laron Posted April 27, 2007 Author Share Posted April 27, 2007 ok thanks, ill see if i can get this Link to comment https://forums.phpfreaks.com/topic/48850-restrict-users-after-certain-amount-of-time/#findComment-239498 Share on other sites More sharing options...
laron Posted April 30, 2007 Author Share Posted April 30, 2007 what is the php function to store it as a timestamp in mysql? what ill the "outcome" looklike, and how will i check it. what kind of variable is the timestamp stored as, int? i guess i dont understand what the timestamp will output to be ex.20070429 and check it if date_now>20080429? or... (stupid q?) Link to comment https://forums.phpfreaks.com/topic/48850-restrict-users-after-certain-amount-of-time/#findComment-241339 Share on other sites More sharing options...
Caesar Posted May 1, 2007 Share Posted May 1, 2007 The timstamp that gets put into the database won't make sense to you when you look at it unformatted. it is basically the date in seconds. But you can easily use that timestamp for comparison in your functions. And you can format it for displaying purposes after. <?php $current_time = time(); $db->connect(); $db->query("INSERT INTO table (reg_date) VALUES ('$current_time') WHERE username = '$username'"); $db-close(); ?> And when you pull it back from the database, you can format the timestamp and do anything you want by comparing any aspect of the timestamp.... <?php $db->connect(); $query = $db->query("SELECT * FROM table WHERE username = '$username'"); $info = $db->fetch_array($query); $db-close(); $registration = $info[reg_date]; $reg_month = date("M", $registration); $reg_day = date("d", $registration); $reg_year = date("Y", $registration); $reg_date = date("M d, Y", $registration); ?> I'm doing three different things at once atm...so I would verify my syntax before trying it :-P Link to comment https://forums.phpfreaks.com/topic/48850-restrict-users-after-certain-amount-of-time/#findComment-242017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.