MP3 Download Codes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

finny
Forum Newbie
Posts: 15
Joined: Mon Apr 24, 2006 7:43 am

MP3 Download Codes

Post by finny »

My friends band have asked me if I would be able to put MP3s up for download on their website which will only be accessible by entering a unique download code. I'm currently trying to learn some php & mysql and was wondering if someone could point me in the right direction about how I would go about this or if it would be completely out of my depth.

The idea is that they are going on a small tour and want to give away tracks to those who turn up to the shows. Each person would be given a sleeve or flyer with a download code which will allow them to download the track once only.

Any help would be great.

Thanks
fin
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Store, in a database, the complete list of codes, a used state to lock out future requests, and a reference to the file.
finny
Forum Newbie
Posts: 15
Joined: Mon Apr 24, 2006 7:43 am

Post by finny »

Thanks for your help. I have no idea how to go about doing that but I guess thats what books are for!


Thanks again.
fin
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post by a94060 »

bascially u will make 1 table wit h3 fields. u have 1 feild for the code, 1 for a Y or N and then u put the mp3's in to one location. then in the last feild u put the location relitave to the script. so when you cal lit by select,you select the code form the db if it exists,fetch the array,if the Y/N field is equal to N,append the location to the url and it should download.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

via aol and spelling translation, a94060 wrote:bascially you will make 1 table with 3 fields. you have 1 field for the code, 1 for a Y or N and then you put the mp3's in to one location. then in the last field you put the location relitave to the script. So when you call it by select, you select the code form the db if it exists, fetch the array, if the Y/N field is equal to N, append the location to the url and it should download.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

You could get even simpler. Just have a database with valid codes & the file for the code. Once the download has been started, remove the code from the database.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post by a94060 »

feyd wrote:
via aol and spelling translation, a94060 wrote:bascially you will make 1 table with 3 fields. you have 1 field for the code, 1 for a Y or N and then you put the mp3's in to one location. then in the last field you put the location relitave to the script. So when you call it by select, you select the code form the db if it exists, fetch the array, if the Y/N field is equal to N, append the location to the url and it should download.
thank you for blowing me off like that. i did not know how to store files into the Database so i could not speak for that.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I think he was referring to your use of 'aolspeak' as opposed to proper english words. What you said was certainly valid, it was just cryptically written ;)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post by a94060 »

yea,i know, but i did not like being corrected like that. i mean i rarely ever see anyone else getting corrected like that.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

a94060 wrote:yea,i know, but i did not like being corrected like that. i mean i rarely ever see anyone else getting corrected like that.
Meet myself :wink:
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

That's because we rarely have people use 'aolspeak' like that ;)
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
cj5
Forum Commoner
Posts: 60
Joined: Tue Jan 17, 2006 3:38 pm
Location: Long Island, NY, USA

Post by cj5 »

Create a login/register system, and once they select a file for download, store user info in a database table with already downloaded mp3info. Welcome to coding PHP. Hey if you can't build it, tell that band I'm looking for a freelance job.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I would do it the feyd way:

Store all the codes + references to specific file in the database... And when someone uses it, simply remove it.
This way you always know who's still allowed...

(If you want to keep some history for some reason, instead of deleting it, move it to a 'used_codes' table)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

a94060 wrote:yea,i know, but i did not like being corrected like that. i mean i rarely ever see anyone else getting corrected like that.
Quite right you are. Sorry about that. I know I make enough typ0s in my posts ;)
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post by a94060 »

d11wtq wrote:
a94060 wrote:yea,i know, but i did not like being corrected like that. i mean i rarely ever see anyone else getting corrected like that.
Quite right you are. Sorry about that. I know I make enough typ0s in my posts ;)

its ok.

d11wtq | Removed text


Im sorry for distracting the topic finny,i think we have all given you our suggestions out here.
Post Reply