-2

I am currently developing a file hosting site just like filehippo.com. I am done with it. But, my client wants a premium membership system similar to rapidshare pro. so, only premium members get the download access in a period of time (like a month or so).

I have two tables now :

  • user
  • file

should I create a new table for the membership status? What's the best practice to do it? the logic and maybe the database structure. please give me some advice.

thanks a lot.

rzkrzzz
  • 1
  • 1

2 Answers2

0

Looks like you just develop or add some columns in the user table and file.

In the user table to add the column user_id, level_access, inactive period. then the file table you can add columns id_user which serves to connect the user table.

possible to set the expiration date interval you make a function like this:

function expiration($date) {
    /* $date = time is a register as user */
$sql=mysql_query("select ('$date' - INTERVAL 1 week ) as expired");
$row = mysql_fetch_array($sql);
$output=$row['expired'];
return $output;
}`
proyeksi
  • 11
  • 3
0

If they are paying for the premium membership, I would create another table and associate it to the transaction id of the payment. This will be a one user row to many premium_access rows. That way you can have a historic record of what payment was used for how many days/months of service and allow to charge discounts for 6 month or yearly memberhips and still have accurate tracking to make sure you can track down any loopholes or exploits.

Then when you want to know when they expire it would just be

select * from premium_access where user_id = '$id' limit 1 order by end_date desc

EDIT: Here is a quick mock up of a possible table structure. Use your own judgment on the columns you will need and the proper naming convention:

CREATE  TABLE IF NOT EXISTS premium_access (
  id INT NOT NULL AUTO_INCREMENT ,
  user_id INT NOT NULL , --fk to USERS
  payment_id VARCHAR(45) NULL , --fk to PAYMENTS/INVOICES
  start_date TIMESTAMP NOT NULL ,
  end_date TIMESTAMP NOT NULL ,
  PRIMARY KEY (id) )
dasper
  • 692
  • 4
  • 13