Page 1 of 1

need help with GET function

Posted: Fri Jan 02, 2009 12:08 am
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.

Re: need help with GET function

Posted: Fri Jan 02, 2009 12:24 am
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

Re: need help with GET function

Posted: Fri Jan 02, 2009 12:30 am
by sherlockholmes47
But then how do you redirect?

Can you give me some kind of code?

Re: need help with GET function

Posted: Fri Jan 02, 2009 1:33 am
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.

Re: need help with GET function

Posted: Sun Jan 04, 2009 10:53 pm
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!