galvin Posted May 7, 2009 Share Posted May 7, 2009 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 More sharing options...
Ken2k7 Posted May 7, 2009 Share Posted May 7, 2009 Have your AJAX function use POST data instead of GET. That way, it wouldn't matter if they went there directly because there would be no POST values. Link to comment https://forums.phpfreaks.com/topic/157172-solved-prevent-manually-going-to-a-file/#findComment-828253 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.