...

View Full Version : Restricting direct access to an include page



stephan_pieri
03-24-2007, 11:06 AM
Hiya guys.

Firstly, thank you for your help on the date() functions, they worked like a dream once i learned them.

I'm having a bit of trouble...i'l give an example below.

I have 2 pages, main.php and include.php.

I have made main.php call include.php and show its contents, but i do not want my visitors to be able to type in www.mydomain.com/include.php and see the contents of the file.

A couple of years back, i remember making a password protection section in PHP, and i think i used a 'if requested, display("restricted area") kind of thing, but i cannot remember.

Could someone just refresh my memory please

jmitch18
03-24-2007, 01:46 PM
Try defining a constant at the top of main.php

E.g.


define('CONSTANT_NAME', true);

Then on your include files, right at the top put this


<?php
if ( !defined('CONSTANT_NAME') )
{
header("location: main.php");
}
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum