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
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

Link to comment
Share on other sites

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
}

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.