Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP Problem

Featured Replies

<?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.

 

:)

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.

and maybe " instead of ' in you fopen ?

You got:

 

include("Location: Location: http://www.myurl.pdf");

 

You mean to repeat Location:?

  • 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.

as they're being opened w or a do they have the correct properties?

  • Author

as they're being opened w or a do they have the correct properties?

 

Such as?

  • 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.

Such as?

 

well ensuring that the files are available to be written to.

  • Author

well ensuring that the files are available to be written to.

 

Yes, I did state that in my original post...

  • 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.

  • 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.