(I want to make free subscription area where members' info is deleted from mysql when 30 days old)

I already have have a members login script.... but i have to manually delete users.....what i really need is to know how to make member expire after so many days with a php script. (free or very cheap) :eek:

Dani AI

Generated

This thread asked how to automatically remove members after 30 days (); was right to push automation. A safer, production-ready approach is: record when a subscription starts or when it should expire, mark expired accounts first (soft-delete), and run a scheduled job that moves or purges records in controlled batches. Hard deletes should be a second step after a grace/archive period to avoid accidental data loss and to preserve referential integrity.

A compact schema change that supports this:

ALTER TABLE users
  ADD COLUMN subscription_start DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  ADD COLUMN expires_at DATETIME NOT NULL,
  ADD COLUMN status ENUM('active','expired','archived','deleted') NOT NULL DEFAULT 'active',
  ADD INDEX (expires_at);

Set expires_at at signup (for example with DATE_ADD(NOW(), INTERVAL 30 DAY)), store times in UTC, and index the expiry column for fast scans.

Run expiration from a daily cron or the MySQL event scheduler (if available). Example MySQL event to mark expirations:

CREATE EVENT expire_users
ON SCHEDULE EVERY 1 DAY
DO
  UPDATE users
  SET status = 'expired'
  WHERE status = 'active' AND expires_at <= UTC_TIMESTAMP();

Best practices: perform deletes/archives in small batches to avoid locks (use LIMIT and repeat), log every automated action, handle related tables (cascade or archive related rows rather than orphaning), and keep backups before any destructive job. Where immediate deletion of personal data is legally required, perform a secure scrub and move audit records instead of blind deletes. These precautions give the automatic flow reliability and a safety net compared with manual removal.

Recommended Answers

All 6 Replies

(I want to make free subscription area where members' info is deleted from mysql when 30 days old)

I already have have a members login script.... but i have to manually delete users.....what i really need is to know how to make member expire after so many days with a php script. (free or very cheap) :eek:

Hello, I can do it for you or if you are PHP programmer can explain how to do :)

Regards

Arsench, you do realize this thread is 5 years old don't you ?!

Arsench, you do realize this thread is 5 years old don't you ?!

No, 5.5 years old and you ?

If you're going to get technical, it's actually 5.20833 years old which makes hashinclude's number more accurate.

Either way, there was no need to reply. Considering the OP only posted 5 times within less than a month of joining, they probably have completely forgotten about this post/thread.

How WOULD you do it anyway? I am intrigued, enlighten me, Arsench :)

on login update lastlogin with sql now() the timestamp of now

delete low_priority from table where last_login < (now() - 2592000 ) order by last_login limit 100

2592000seconds=30 days
limit 100 to make sure no timeout and because a limit is usefull where there may be 10000000 members
low priority to ensure the login page the code is embedded in presents without delay

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.