Jump to content

[SOLVED] prevent manually going to a file?


galvin

Recommended Posts

I have an AJAX function that calls to a file call addcount.php. So someone could view source and see that I have a file called addcount.php. Is there a way with PHP (or anything else) to prevent someone from going to a file directly (i.e. by typing the file name into the browser)? 

 

Like if someone manually typed addcount.php into the browser address bar, I wouldn't want it to run the code on that page, so maybe it could redirect them to another page and not run the code?

 

I guess I could somehow declare a variable and then on addcount.php put some code that says if the variable is not set, redirect.  Hmmm, I guess that would work.

 

But is there any other way that I'm missing?

 

Link to comment
https://forums.phpfreaks.com/topic/157172-solved-prevent-manually-going-to-a-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.