Reply to topic
PHP Script Not Working After Migrating To HMS
Hobartimus


Joined: 24 Nov 2006
Posts: 48
Reply with quote
I am having a strange issue with a PHP script that I have been using for years at another hosting company. It is a simple file download script which allows visitors to download a file from a specific directory without being able to view the contents of that directory.

It is comprised of four items...
index.php
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>File Download</title>
</head>

<body>
<b>Retrieve Your File</b>
<p>Be sure to use the EXACT file name including extension or this form will not retrieve your file.</p>
<form action="downloadfile.php" method="POST">
<p>File:&nbsp;<input type="text" name="filename" size="20"></p>
<p><input type="submit" value="Get This File"> <input type="reset" value="Reset"></p>
</form>
</body>
</html>


downloadfile.php
Code:
<html>
<head>
<title>Web Download</title>
</head>

<?php
$link = "/outbox/$filename";
?>

<frameset cols=0,* frameborder=NO border=0 framespacing=0>

<frame name=dnld scrolling=NO noresize src="<?echo $link?>">
<frame name=main scrolling=NO src=download_success.php>
</frameset>
<noframes>
<body bgcolor=#FFFFFF>
</body></noframes>

</html>


download_success.php
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Download Success</title>
</head>

<body>
<b>Thank You!</b>
<p>Your file should begin downloading now.</p>
</body>
</html>


and the outbox directory which contains files available for download.

So, I have uploaded these files to my HMS webspace and set permissions as normal, but when I try to retrieve a file I get the following error...
Notice: Undefined variable: filename in /vservers/subfluid/htdocs/download/downloadfile.php on line 7


"Line 7" being $link = "/outbox/$filename";

I am just at a complete loss because I have never had trouble with this script in the years I have been using it. Could it have anything to do with server settings here at HMS?
Difference
comprug
Forum Regular

Joined: 15 Feb 2006
Posts: 343
Reply with quote
Howard - sorry about your troubles with PHP. Honestly, I don't know what broke the script with HMS, but usually, I do this:
Code:
<?php $link = "/outbox/$_POST['filename']"; ?>

Thanks
Hobartimus


Joined: 24 Nov 2006
Posts: 48
Reply with quote
Thanks for the suggestion, but I just tried it and got the same error.

I'm totally stumped.
dbodner


Joined: 21 Dec 2005
Posts: 112
Location: Philadelphia, Pa
Reply with quote
It sounds like your previous host had register globals turned on. You can do this in the HMS control panel, under PHP Settings. The code suggestion comprug posted should work, but your entire script is likely designed around register globals being turned on, so you probably want to toggle them on in the control panel, then try your original script.
Hobartimus


Joined: 24 Nov 2006
Posts: 48
Reply with quote
That did the trick.

Thanks a bunch!
PHP Script Not Working After Migrating To HMS
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic