...

View Full Version : preventing access to sub-pages



sweenster
01-27-2004, 01:12 PM
i want to set my site up in such a way so that the only way someone can view it is by the "front door" i.e. by loading the index.php page.
When they type in (say) 'main.php' i want main.php to reject it and divert them to the index.php page.

index.php uses a session and loads all sub-pages by include statements. Is there a command that can detect if a session is present and allow the user to pass, but throw them out if not?

Nightfire
01-27-2004, 03:27 PM
Something like this?



<?php
session_start();
if(!isset($_SESSION['session_name'])){
header("Location: index.php");
}
?>

sweenster
01-27-2004, 06:42 PM
sort of... -ish.

index.php has following code:



<?php session_start();
if ($statnum == "0") {
include('../index.php');
die;
}
include('../header.php');
include('../pageheader.php');
include('sqlconnect.php');
include(''.$load.'.php');
?>

</body>
</html>


i only want this site to be accessed through (for example) "index.php?load=main"

needing a line of code i can put on main.php that will detect if a session is not present (i.e. page hasn't been loaded by the index)and run index.php.

would above code work??



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum