Jump to content

PHP Script for 30 days premium


alesyt0h

Recommended Posts

Hello! I have a site with premium memberships, but PHP script is not working well..

 

I the table accounts I have a column called reset_timer(default value is 0). When someone purchase a new premium membership, PHP add with time(); function into the reset_timer.

 

Premium is 1 month yes and is working well, but the "countdown" script is not working, the script take only the first reset_timer value so for example if the user1 purchase premium membership today, after 5 days, he have 25 days left, but if somebody in another account purchase 1 month of premium, he have 25 days left too, because script only taking the first reset_timer value.. This is the code:

 



function time_reset()
{
    $now = time();
    DB::select('accounts');
    $timer = DB::fetch_row();   
    $timer = $timer['reset_timer'];
    $difference = ($now - $timer);
    return (2629743 - $difference);
}


 

This is my table structure:

x7vhb.png

 

How I can do it for the script look in every account and reset timer for work correctly?

 

Thank you very much!

Link to comment
Share on other sites

Because this

    DB::select('accounts');
    $timer = DB::fetch_row();

Is first getting all the accounts from the accounts table. Then on the next line it gets the first result from the table which will always be the first record in the table. You need to change your query so it only gets the record for the user you are renewing the membership to.

 

Also if you used a date time field mysql can update the reset_timer field using one query like this

UPDATE accounts SET reset_timer=DATE_ADD(CURDATE(), INTERVAL 1 MONTH) WHERE id=$user_id
Edited by Ch0cu3r
Link to comment
Share on other sites

Hello Ch0cu3r, thank you for the reply!

 

So what I need to change?

 

reset_timer field for default is 0 value.

When someone purchase one month of premium is used by php with this: UPDATE accounts SET reset_timer = '$time' WHERE username = '$username'";  

So everyone that purchases premium have a long numbers in reset_timer field.

 

What I need to change in the php for select each record in the table? 

Thx!

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.