PHP prevent direct file access
PHP prevent direct file access
Some months before i have written a code using PHP to prevent direct file access but now i have modified the previous script since it has some set backs, Let us take one file named MYFILE.PHP as an example, all you have to do is just add the below code on the top of all the script.
< ?php if (!empty($_SERVER['SCRIPT_FILENAME']) && 'MYFILE.PHP' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!'); ?>
Always remember to change the file name accordingly.I have given that area in BOLD and CAPS
PHP prevent direct file access,
I’m happy! It is simple to see that you are passionate about your writing. Looking forward to future posts. Thanks!