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? Link to comment https://forums.phpfreaks.com/topic/115528-include-help/ 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"); Link to comment https://forums.phpfreaks.com/topic/115528-include-help/#findComment-593912 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 Link to comment https://forums.phpfreaks.com/topic/115528-include-help/#findComment-593939 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.