Babak Mehrabi
Babak Mehrabi

Reputation: 2275

Account Expiration in MySql

I am working on a site where I have users with registration and duration time is 6 month or one year. I save the registration time for each user. Now I use PHP to handle this situation. Each time the user logs in, I check username and password and also I check that the time after registration date is not over.

Is there any way to use mysql to handle this automatically for me?

Upvotes: 1

Views: 647

Answers (2)

Code Prank
Code Prank

Reputation: 4250

You can also try this one:

select * from tbl where username = $user AND password = $pass AND SYSDATE() > DATE_ADD(registration_date, INTERVAL 6 MONTH)

Upvotes: 0

Fluffeh
Fluffeh

Reputation: 33512

Use an extra set of conditions in the query where clause (that verifies the user) that will only select the user details if the extra condition is met:

where
    // normal clauses
    and userExpires>CURDATE()

Upvotes: 2

Related Questions