PHP redirect of direct access to include files
I have 5 php files that are included into an index.php file. How can I use php to ensure that these include files are not accessed directly in anyway, except from the include DIR?
Veselin
August 27, 2006, 1:57 pm
Re:
In your index.php file before including the files you can set a variable like
$INCLUDE_PASS = 'somepass';
then in the includes files you can have
if ($INCLUDE_PASS = 'somepass') {
/// include file content
} else {
echo "Error message";
};
this way if someone opens http://www.domain.com/include1.php it will do nothing because if ($INCLUDE_PASS = 'somepass') statement will be false and will show the error message.