Expire?
Moderator: General Moderators
Now, that depends. Are you storing the usernames in a database? Do they require passwords? You could use cookies, but that probably wouldn't be the best way to approach it.
When the user signs up you could along with entering the username and password in the database add the date or time. Then if when you have users login you could check to see if it has been 30 days since they first registered. If it has, then delete their account.
Or you could make and admin page and ever time you run it it would check all the users dates are less than 30 days old.
Hope this helps.
When the user signs up you could along with entering the username and password in the database add the date or time. Then if when you have users login you could check to see if it has been 30 days since they first registered. If it has, then delete their account.
Or you could make and admin page and ever time you run it it would check all the users dates are less than 30 days old.
Hope this helps.
don't delete the account, simply disable it. Create a column in the DB 'enabled' and make it default to 'Y' and after 30 days change it to 'N'. Then check their enabled status before allowing one to log in. I assume that you would want to keep their info around or allow them to re-enable the account for some reason - if not, then delete them I guess. 
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Hope that this would help.
One thing that you need to consider is the data type of your user_regdate field. If it is a timestamp field then it would be ok but if it is not, then you need to use mktime function to convert it to timestamp.
To determine the timestamp of the current date, you may try the following code:
Hope that this helps.
Junrey
One thing that you need to consider is the data type of your user_regdate field. If it is a timestamp field then it would be ok but if it is not, then you need to use mktime function to convert it to timestamp.
To determine the timestamp of the current date, you may try the following code:
Code: Select all
$today = getdate();
// just in case you will consider the time, hour : minute : seconds
$currentTimestamp=mktime($todayї'hour'], $todayї'minute'], $todayї'second'], $todayї'mon'], $todayї'mday'], $todayї'year']);
// then determine the difference between the date of registration and the
// current timestamp. Supposing that you have the variable
// $regTimestamp that serves as the timestamp of the registration
$diff = $currentTimestamp - $regTimestamp
// the $diff variable now contains the difference in seconds. so u may
// need to divide it with 3600 to determine the number of days.Junrey
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Personally I think storing dates in MySQL in anything other than DATE, DATETIME, TIMESTAMP or as a UNIX timestamp in an INT column is pointless as it leads to truly unneccessary hassle when you try and sort or print these dates.
Anyway, you could use PHP to work out whether or not membership had expired (was 30 days later than subscription date) by doing:
Some of the code is redundant but is there to show logic more than anything.
Check out:
http://www.php.net/strtotime
http://www.php.net/time
Mac
Anyway, you could use PHP to work out whether or not membership had expired (was 30 days later than subscription date) by doing:
Code: Select all
<?php
$db_date = 'Mar 12, 2003';
$registered_date_timestamp = strtotime($db_date);
$thirty_days = 30*24*60*60;
$now = time();
$expired = $now - $thirty_days;
if ($registered_date_timestamp > $expired) {
echo 'ok';
} else {
echo 'expired';
}
?>Check out:
http://www.php.net/strtotime
http://www.php.net/time
Mac