I've been using this site to look for answers but I can't find any that may help so I decided to create an account and ask myself.
Here is a link to the website that I'm working on http://www.h-elpsystems.co.uk/index.php. It's a database driven website which allows users to download files. Now I was working on one page of the website (as far as I'm aware I didn't touch any of the code that used the download code) and now all of a sudden the downloads don't work.
The downloads are located on the "employment law page" at the bottom. When you click on the link to download a file it just sends the user to the same page only with a # in the URL at the end.
I'm not sure which bit of code to upload (I'm new to php) but if someone will let me know which is needed I'll upload it.
Thanks for any help in advance.
PS here is the code that I'm using for the download. (note I didn't create the code, I just edited a page or two and the downloads seemed to have stopped working for some reason.)
<?
// Define the path to file
$file = "membersfiles/".$_GET['ID'];
if(!file)
{
// File doesn't exist, output error
die('file not found');
}
else
{
// Set headers
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: binary");
// Read the file from disk
readfile($file);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Download file</title>
</head>
<body>
</body>
</html>
Also below is the code for the employment page. (Sorry I'm new to this forum so didn't really know what to include in the question)
<?
session_start;
include("../Functions.inc");
$ID=PageID(substr(dirname($_SERVER['PHP_SELF']), 1, strlen(dirname($_SERVER['PHP_SELF']))));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><? echo PageTitle($ID);?></title>
<meta name="keywords" content="<? echo PageKeywords($ID);?>" />
<meta name="description" content="<? echo PageDescription($ID);?>" />
<meta name="robots" content="index,follow" />
<link href="../mainstyles.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="leftcolumn"><div id="mainnav"><img src="../media/logo.gif" alt="H-elp Systems" /><? include("../Left-Links.inc"); ?>
<a href="mailto:info@h-elpsystems.com" id="emailbutton" ><span>click here to email us</span></a>
<img src="../media/navfooter.gif" alt="Help Systems" /></div>
</div>
<div id="centercolumn">
<div id="topnav">
<? include("../Top-Links.inc"); ?>
</div>
<div id="content">
<img src="../media/headers/<? echo PageTitle($ID);?>.jpg" alt="" />
<img src="../media/splashtext/<? echo PageTitle($ID);?>.gif" alt="When it come to employment you need h-elp systems" /><a href="#" id="phonelink" ><span>0121 635 5870</span></a>
<img src="../media/hr450.gif" alt="Help Systems" />
<div id="contentcopy">
<h1><? echo PageSplash($ID);?></h1>
<? echo PageContent($ID);?>
<?
$query = "SELECT * FROM `Files` WHERE `Employment`=1";
$result = mysql_query($query) or die ("Failed To get member files!");
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print("<img src=\"../media/hr450.gif\"/><br><a href=\"#\" onclick=\"javascript:downloadwindow('../Download.php?ID=".$line['URL']."');\">".$line['URL']."</a>");
}
?>
</div>
<img src="../media/hr450.gif" alt="Help Systems" />
<div id="footer">
<p>RJS Management Services Ltd Concorde House Trinity Park Solihull B37 7UQ<br />
Tel.+44 (0)121 635 870 Email. <a href="mailto:action@h-elpsystems.com">action@h-elpsystems.com</a></p>
</div>
</div>
</div>
<div id="rightcolumn">
<?
$query = "SELECT * FROM `News` ORDER BY `Date` DESC limit 0, 4";
$result = mysql_query($query) or die ("Failed To get latest news!");
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$ShortContent=substr($line['Content'],0,175);
print("<h2>".$line['Title']."</h2>".$ShortContent."...<p class=\"small\">".$line['Date']."</p><a href=\"../News.php?Article=".$line['ID']."\" class=\"clickformore\" ><span>click here for more</span></a><img src=\"../media/hr.gif\" alt=\"H-elp\" />");
}
?>
</div>
</div>
</body>
</html>
<?
//Close any open connetions
mysql_close;
?>
edit: I've tried everyone's answers and they seem to work in some form but for some reason when i upload the changed code to the server it seems to bring up a blank page when ever I click on the employment law page. Now I don't know if I'm saving it wrong or uploading it wrong or if something else is wrong.