I am going to write user registration in php and don't want to use any framework. Usually it looks like this:
In first step i add user information into a special database table that stores inactivated users. In third step i move user from that table into the table for activated users.
I have a few question:
Thanks!
There is no need of using php session mechanism to delete the data from db,"as you said in comment"
You can delete the data when you want. May be in 24 hours or 7 days or 1 month. May be it is depend upon traffic you will obtain.
But as soon as user registers store the time in reg_time
column. By which during deletion the comparison will done with reg_time
.
if you want to delete after 24 hours then
delete from ACCOUNT_TBL_DETAIL
where usrActivated=0 AND regTime <= UNIX_TIMESTAMP(DATE_SUB(now(), INTERVAL 1 DAY));
After 7 days
delete from ACCOUNT_TBL_DETAIL
where usrActivated=0 AND regTime <= UNIX_TIMESTAMP(DATE_SUB(now(), INTERVAL 7 DAY));
To schedule SQL script
CREATE EVENT delete_event
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 DAY
ON COMPLETION PRESERVE
DO BEGIN
DELETE messages WHERE date < DATE_SUB(NOW(), INTERVAL 7 DAY);
END;
this is a simple cron script