September 5, 201016 yr <?php $reqFile = $_POST["file"]; if (!isset($reqFile)) { header( "Location: http://www.myurl....." ); } else if ($reqFile == "p"){ $myFile = "testFile1.txt"; $fh = fopen('testFile1.txt', 'w') or die("can't open file1"); $stringData = "Download Requested\n"; fwrite($fh, $stringData); fclose($fh); include("Location: Location: http://www.myurl.pdf"); } else if ($reqFile == "c"){ $myFile = "testFile2.txt"; $fh = fopen($myFile, 'a') or die("can't open file2"); $stringData = "Download Requested\n"; fwrite($fh, $stringData); fclose($fh); header("Location: http://www.myurl.....pdf"); } else{ include "Location: http://www.myurl....."; } ?> I'm creating a download counter which writes download requests to text files. However, my "die" statements are being echo'd back at me so it's as if it can't find the txt files even though they exist in the "downloads" folder along with the above PHP file. Have tried using the complete URL for each text file but this has not worked either. Would love some help.
September 5, 201016 yr is the Location: necessary for Include statements. As far as I know you don't need it. not sure if that is in some way screwing up things.
September 5, 201016 yr Mmmmmm yea i have no clue why ur using Location in an include that is suppose to be used in header();
September 5, 201016 yr you use location when you use headers header('location: http://www.gotothisurl.co.uk'); which will send you to a new page.. with include, just do include('file_to_include.php'); or include 'http://www.example.com/file.php; for a full path
September 5, 201016 yr You got: include("Location: Location: http://www.myurl.pdf"); You mean to repeat Location:?
September 5, 201016 yr Author I had headers originally but changed to include just to test. That being said, that segment of the if statement isn't getting as far as that as it is not locating the original file so not convinced include/header would make a difference at this point.
September 5, 201016 yr Author as they're being opened w or a do they have the correct properties? Such as?
September 6, 201016 yr Author Why not just use mysql? That was my proposal originally and I may still do that but I would still like to know why it's not working.
September 6, 201016 yr Author well ensuring that the files are available to be written to. Yes, I did state that in my original post...
September 6, 201016 yr where? I see no mention of permissions, you just say that the files are there.
September 6, 201016 yr Author where? I see no mention of permissions, you just say that the files are there. The files are there on the server. What do you mean by permissions? If you mean something along the lines of -rw-r--r-- then this is what the text files are.
September 6, 201016 yr Author where? I see no mention of permissions, you just say that the files are there. Ah got you now, spot on. Changed permissions to write. Good man, +1.
Create an account or sign in to comment