|
| |
|
|
shoky
Posts: 30 Joined: 9/13/2005 Status: offline
|
Expire an account by date - 7/27/2009 16:54:23
Hello - I'm thinking of setting up a members area where accounts expire. Any ideas on how to write a script(SQL) that reads a Date from the database and sets accounts to parked if the date has passed. Thanks!
|
|
|
|
womble
Posts: 6007 Joined: 3/14/2005 From: Living on the edge Status: offline
|
RE: Expire an account by date - 7/27/2009 18:24:05
I've been at work all day so brain's dead now and I'm no good at figuring out SQL queries when I'm half asleep, but I'd imagine you'd need to use one of the SQL date functions to check the current date against a date on the account, (whether that's the date the account was created, the last time it was accessed, or whatever) and then use a simple update query to set a field for whether an account's active or not (say '1' for an active account, and '0' for an inactive account). The update query would update the value for that field if the current date was after whatever date you're checking. Probably somewhere you'd need to use either the NOW() or CURRENT_DATE() functions (again, if you're using MySQL), or possibly the TIME() function. Something like: $today = time(); $query = "SELECT * FROM accountstatus WHERE expires > $today"; would select all records where the the expiry date was greater than the current date and you could use an update query to set the status of the account to active, or conversely check whether the current date's after the expiry date and use an update query to set the account status to '1' or '0.' 'Expires' would be a datestamp. Like I said, my brain's packed up for the day so there's no guarantees that the above will make any sense whatsoever, but that help any?
_____________________________
~~ "A cruel god ain't no god at all" ~~ ~~ Erase hate. Practice love. ~~
|
|
|
|
shoky
Posts: 30 Joined: 9/13/2005 Status: offline
|
RE: Expire an account by date - 7/28/2009 10:04:40
OK - Thanks - I'll try the ideas out. Just one related question: To enter the date in the Database what is the proper syntax using Access db: "',expiredate='" & request.Form("expiredate") & Right now it's a text field but I know it needs to be date/time
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|