Page 1 of 1

redirecting errors

Posted: Mon Jul 07, 2003 10:12 pm
by DuFF
Hey, I've been having some trouble using headers to redirect the user to another page. My host is Lycos and I'm using IE6 (if those could be the problem). Heres an example of something that won't work, I've had numerous redirects not work although a couple do, I'm very confused about this. The following code is used to count the number of downloads:

mapdl.php

Code: Select all

<?php
include("header.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="UPDATE files SET downloads=downloads+1 WHERE file='$file'";
$result=mysql_query($query);
mysql_close();
$dlpage = $_SERVER['DOCUMENT_ROOT'] . $file . "/";
$redirect = "Location: $dlpage";
header ($redirect);
?>
An example link to this would be: mapdl.php?file=maps/as_oilrig.bsp. But when I click the link to download it goes to the above page and just stays there and won't redirect the user. Is there anything I'm doing wrong? Any help would be appreciated.

Posted: Mon Jul 07, 2003 10:31 pm
by m3rajk
chec the headers warning thread, as well as searching. there has been a number of threads on this type of thingsince i gothere.


also, you should understand that microsoft has NEVER conformed to w3c. unless you want the site specifically for those that use ie, dl at least one w3c complaint browser. at this point the most popular two are Mozilla ( http://www.mozilla.org ) and opera (http://www.opera.com ).

i suggest mozilla if you only get one because mozilla is opensource and supported by legions of people that are into that because when netscape was on version 2 or 3 they created an opensource project (mozilla) to help speed along the browser egine development, and netscape would borrow engine upgrades.

if it works right in mozilla, then rest assured the issue is ie being non-compliant

Posted: Mon Jul 07, 2003 10:45 pm
by DuFF
Thanks for the tips, I looked at the header post and realized I had whitespace in my included header.php, that was the problem. Now this brings up another question, how can I make the user download the file being pointed to, not just open it. Right now the download redirects to a .txt file so the text is displayed in the browser. Is there a way to make sure that the file is downloaded instead of displayed?

Posted: Tue Jul 08, 2003 10:33 am
by m3rajk
only thing i can think of is renaming the extenson to something windows wont recognise (blah.text.thisisafakeextension)

Posted: Tue Jul 08, 2003 12:53 pm
by DuFF
It's ok, I've got it working well now. :D