Reputation: 2275
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
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
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