When a user registers on my site there status is 0 (not active) ... meaning they not activated there account via email. When they register i also store the DATETIME they registered, i store it in MySQL using MySQL DATETIME and using
NOW() in my INSERT query on registration.
Format stored as:
0000-00-00 00:00:00 .
I want to be able to delete everything from
users table where
status = 0 (not active) and where a user has not activated there account within 48 hours.
My MySQL query so far is:
SELECT * FROM users WHERE user_status = 0 AND user_registered // not sure what i do here.
Could someone tell me how i go about checking if 48 hours have elapsed and account is still not activated ? the first part of query i think i got rite, its the AND bit etc im not sure about.
Basically i will create a script to run on a cron job every 24 hours ( i know how to do the cron job in cpanel) at low peak times, but to ensure i don't cause havoc with the server resources (on shared hosting) i want the script to delete xx records and then pause for a while to make sure it does not effect system resources and lock up MySQL.
any help much appreciated, if anyone has a sample script that would be great. One thing that came to mind was as i have access to my php.ini file i set the time in php.ini to UK time where i am, but i know the server i am on is in US so i guess that MySQL will use the server time in the US, not sure how i go about that. Another note is i use PHP PDO but not OOP as not learnt OOP yet.