SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2004
    Location
    Syria
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A download link that changes!

    I'm writing a script for selling webtemplates, when customer buys a template the download link will be sent to his email. Do you have an idea how may this link becomes inactive after a certain period of time (two days for example), so when another customer buys the same template he'll get a different link in order to download the same template which becomes (the link) inactive after 2 days, and so on...

    Do you have some idea how this can be done? Can you tell me about a good tutorial or something?

    I'm a PHP beginner, and this is the first time I program a REAL script

    Thanks,

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You basically just make a database with an int primary_key+auto_increent identifier as well as an int timestamp field. Then when you send the e-mail, you insert, then use mysql_insert_id to get it, then link to file.php?id=10928 and then on file.php you select where id=$_GET['id'] && timestamp > time()-60*60*24*2 (60 seconds, 60 minutes, 24 hours, 2 days) and you're good to go. Then you could use a cron job to purge all items that are < time()-60*60*24*2 so your databse doesn't get full.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •