Jump to content

restrict users after certain amount of time


laron

Recommended Posts

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
Share on other sites

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
Share on other sites

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
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.