Jump to content

Delete row after 1 month


iChriss

Recommended Posts

Hello everyone

 

I am coding a membership system for my usersystem on my website and I needed a little help. I have searched around quite a bit and can't find a working code.

 

In my database I have the date the VIP was purchased and I was wondering if anyone had a code which would check if they've had VIP for over a month and if so, delete it from the database.

 

I'm new-ish to MySQL and PHP and can't seem to code a working one.  :shrug:

Link to comment
https://forums.phpfreaks.com/topic/225150-delete-row-after-1-month/
Share on other sites

username (The user's username)

rank ( 1= Normal User 2= VIP)

vip_purchased (The date the VIP was purchased, preferably in the format: Y/m/d)

 

They are all VARCHAR but I can change/add anything if needed

 

So I want the rank to change back to 1 after a month has passed since vip_purchased

I would store the vip_purchased as an int(10) and populate it with the time() function at the time of purchase

 

You can then check when 1 month has passed with this code

 


// (time() - $vip_purchased) - Number of seconds since time of purchase
// (60*60*24*31) - Number of seconds in 31 days

if(((time() - $vip_purchased) > (60*60*24*31))
{
// VIP Time Expired
}

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.