djjjozsi;10904825 wrote:Hello
if you send a file to the browser with readfile you can set a file name what ever you want.
if this song is in a database, create the download link where you pass the mp3's primary ID like:
domain.com/dl.php?song=222
in dl.php select from database where Id is 222, and readfile . the example is on php.net.
hello,jjozsi.
i have a database for my shorturl.php page
CREATE TABLE redirect (
link_id int(11) NOT NULL auto_increment,
link_url text NOT NULL,
link_desc text NOT NULL,
link_count int(11) NOT NULL default '0',
PRIMARY KEY (link_id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Short URL';
and i want that when someone click on the created link
http://www.domain.com/song.php?101
the download file name can convert into the description(text) of the database
and the page code is here to provide check the link:-
<?php
$Path_To_Script = "";
$Database_Username = "";
$Database_Password = "";
$Database_Name = "";
$Database_Host ="";
$Not_Found = "";
$get_id = $_SERVER['QUERY_STRING'];
function shorturl_error($error){
echo $error;
}
if($get_id){
$DBConn = mysql_connect($Database_Host, $Database_Username, $Database_Password) or die(shorturl_error("Could not connect to database server. Check your settings."));
$DB_DB = mysql_select_db($Database_Name, $DBConn) or die(shorturl_error("Could not connect to database ($Database_Name). Perhaps you don't have the right permissions on this DB. Check your settings"));
$sql = mysql_query("SELECT redirect FROM redirect WHERE link_id='$get_id'");
$site_arr = mysql_fetch_array($sql);
$site_redirect = $site_arr['link_url'];
if(!$site_arr){ header("Location: $Not_Found"); }
if($site_arr){
mysql_query("UPDATE redirect SET link_count = link_count + 1 WHERE link_id='$get_id'");
header("Location: $site_redirect");
}
}