need help with GET function

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

Post Reply
sherlockholmes47
Forum Newbie
Posts: 3
Joined: Sat Nov 08, 2008 11:40 pm

need help with GET function

Post by sherlockholmes47 »

Now I'm making a songs download site as a project and this is the thing which I need help with :

How to write code to be able to download the files using the get method?

I am using the address like : http://localhost/songs.php?sid=1

I am able to retireve the data from the database using this GET but I want that the song should immediately be available for download. Nothing should be displayed.

the mysql table i'm using :

tablename : song

table fields :
  • songid
    songname
    songurl

Code: Select all

<?php
include('connection.php');
 
$songid=$_GET['sid'];
 
$query=sprintf("SELECT * FROM songid where songid = %d",$songid);
$result=mysql_query($query);
 
while ($row = mysql_fetch_array($result))
        {
              [color=#FF0000][b]"What should I write here so that the song's download starts"[/b][/color]
        }
        mysql_free_result($result);
 
?>
Thanks in advance.
esmarts
Forum Newbie
Posts: 14
Joined: Fri Aug 08, 2008 10:05 pm

Re: need help with GET function

Post by esmarts »

My guess would be to simply query the song by ID like you did and then query the Song url. After you got the information pulled form the database
I would do a redirect to the song url for download..

Thats just me though..
I am fairly new at this as well and but thats my anwser
sherlockholmes47
Forum Newbie
Posts: 3
Joined: Sat Nov 08, 2008 11:40 pm

Re: need help with GET function

Post by sherlockholmes47 »

But then how do you redirect?

Can you give me some kind of code?
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: need help with GET function

Post by watson516 »

I believe you just have to set the correct headers and what not. I found a pretty good example of exactly what you're looking for after a few seconds worth of googling. You can find it here.
sherlockholmes47
Forum Newbie
Posts: 3
Joined: Sat Nov 08, 2008 11:40 pm

Re: need help with GET function

Post by sherlockholmes47 »

watson516 wrote:I believe you just have to set the correct headers and what not. I found a pretty good example of exactly what you're looking for after a few seconds worth of googling. You can find it here.
Thanks for the link!
Post Reply