rocky48 Posted November 17, 2016 Share Posted November 17, 2016 I am coding some pages for a club website, where I want to restrict access to a members area. I have got the logging in all working, but I have just introduced logout.php to logout of the restricted area. When I run this file I get the following error: ( ! ) Warning: require_once(includes/config.inc.php): failed to open stream: No such file or directory in D:\wamp\www\MFC1066\includes\logout.php on line 4 Call Stack # Time Memory Function Location 1 0.0010 367672 {main}( ) ...\logout.php:0 ( ! ) Fatal error: require_once(): Failed opening required 'includes/config.inc.php' (include_path='.:\wamp\www\LoginTest\includes;D:\wamp\www\lib\PHPMailer') in D:\wamp\www\MFC1066\includes\logout.php on line 4 Call Stack # Time Memory Function Location 1 0.0010 367672 {main}( ) ...\logout.php:0 This is wierd, as the file is certainly there, as I use this file in each header file. Here is the logout.php file: <?php # Script 16.9 - logout.php // This is the logout page for the site. require_once ('includes/config.inc.php'); $page_title = 'Logout'; include ('includes/header1.html'); // If no first_name session variable exists, redirect the user: if (!isset($_SESSION['first_name'])) { $url = BASE_URL . 'index.php'; // Define the URL. ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } else { // Log out the user. $_SESSION = array(); // Destroy the variables. session_destroy(); // Destroy the session itself. setcookie (session_name(), '', time()-300); // Destroy the cookie. } // Print a customized message: echo '<h3>You are now logged out.</h3>'; include ('includes/footer1.html'); ?> I'm wondering if it's anything to do with my session? The seesion starts when the user logs in. How do you maintain the session on all of the pages that I may add in the members area, until they logout? Any advice would be appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/302553-include-file-not-found/ Share on other sites More sharing options...
Solution rocky48 Posted November 17, 2016 Author Solution Share Posted November 17, 2016 Sorry solved it! Put the logout.php in the wrong folder. Should not have been in the includes folder. Quote Link to comment https://forums.phpfreaks.com/topic/302553-include-file-not-found/#findComment-1539395 Share on other sites More sharing options...
NotionCommotion Posted November 17, 2016 Share Posted November 17, 2016 This is wierd, as the file is certainly there, as I use this file in each header file. I know you think the file is there, but I would bet 10-to-1 odds that it isn't where you think it is. Are you attempting to access it from a file located in a different directory? When in doubt, try absolute file paths. Quote Link to comment https://forums.phpfreaks.com/topic/302553-include-file-not-found/#findComment-1539396 Share on other sites More sharing options...
cyberRobot Posted November 17, 2016 Share Posted November 17, 2016 (edited) ...try absolute file paths. Note that URL include wrappers needs to be enabled on the server for absolute paths. As an alternative, you can use a root-relative path. The require_once, require, etc. statement just needs to start with $_SERVER['DOCUMENT_ROOT'] Edited November 17, 2016 by cyberRobot Quote Link to comment https://forums.phpfreaks.com/topic/302553-include-file-not-found/#findComment-1539398 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.