fighnight Posted July 18, 2008 Share Posted July 18, 2008 I need help on including stuff that is inside my html root file. Instead of using this ../page.php is there any other way to include like have a base defined? Quote Link to comment Share on other sites More sharing options...
Stephen Posted July 18, 2008 Share Posted July 18, 2008 You could use: include($_SERVER["DOCUMENT_ROOT"]."/index.php"); This will go to the root of the folder. Example 2 include($_SERVER["DOCUMENT_ROOT"]."/includes/header.php"); Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted July 19, 2008 Share Posted July 19, 2008 or you can do this... <?php // get the page $page = $_GET['page']; // Now, test the URL query for security if ( !is_file ( $_SERVER["DOCUMENT_ROOT"]."/$page.php" ) && $page != "" ) { // File not found! header ( "Location: index.php?page=home" ); } // Are you in index? elseif ( $page == "" ) { $page = "home"; } // Calling the specific page require_once( $_SERVER["DOCUMENT_ROOT"]."/$page.php" ); ?> <a href="index.php?page=page2">Page 2</a> Regards ACE Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.