ShaolinF Posted January 25, 2008 Share Posted January 25, 2008 Hi Guys, So I am including a file (include("mailme.php") -- The problem is people can directly access this file, something which I don't want, so what methods could I use to protect this file from direct access ? Link to comment https://forums.phpfreaks.com/topic/87694-solved-protect-file-from-direct-access/ Share on other sites More sharing options...
revraz Posted January 25, 2008 Share Posted January 25, 2008 Use sessions or a referer. Link to comment https://forums.phpfreaks.com/topic/87694-solved-protect-file-from-direct-access/#findComment-448562 Share on other sites More sharing options...
ShaolinF Posted January 25, 2008 Author Share Posted January 25, 2008 Im thinking of creating a random number, store it in a session and compare it in the mailme.php file. What do you think ? Link to comment https://forums.phpfreaks.com/topic/87694-solved-protect-file-from-direct-access/#findComment-448564 Share on other sites More sharing options...
revraz Posted January 25, 2008 Share Posted January 25, 2008 Set a session in the page that calls it and check that session. It can be anything at all, they won't be able to set the session variable so really no need to make it a random number. Link to comment https://forums.phpfreaks.com/topic/87694-solved-protect-file-from-direct-access/#findComment-448565 Share on other sites More sharing options...
resago Posted January 25, 2008 Share Posted January 25, 2008 put it in a directory higher than public_html Link to comment https://forums.phpfreaks.com/topic/87694-solved-protect-file-from-direct-access/#findComment-448571 Share on other sites More sharing options...
legohead6 Posted January 25, 2008 Share Posted January 25, 2008 have a script on it that gets the current webaddress, if its not the page that its included on, then redirect people away, or just exit the script and display an error message. Link to comment https://forums.phpfreaks.com/topic/87694-solved-protect-file-from-direct-access/#findComment-448623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.