Привет, я пытаюсь создать сайт только для членов, я пытаюсь создать скрипт с сеансами и т. Д. Однако, когда я нажимаю кнопку входа в систему, я получаю следующую ошибку:
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'prepend.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in Unknown on line 0
Я не уверен на 100%, что все это значит, поэтому я выложу свой сценарий и буду признателен, если кто-нибудь сможет рассказать мне подробно, где я ошибаюсь, поэтому я могу понять и узнать о будущем, что я делаю неправильно ,
Заранее благодарим за вход и помощь.
index.php
<div id="maincontentWrapper"> <div id="maincontent"> <div id="contentWrapper"></div><!--End loginWrapper --> <article> <p>Welcome to iManage, please login in below.</p> </article> <div id="loginform"> <div id="loginWrapper"> <form id="loginForm" method="POST" action="classes/class.Login.php"> <h1><span class="log-in">Log in</span> or <span class="sign-up"><a href="register">sign up</a></span></h1> <div id="errorDiv"><?php if (isset($_SESSION['error']) & isset($_SESSION['formAttempt'])) { unset($_SESSION['formAttempt']); print "Errors encountered<br/>\n"; foreach ($_SESSION['error'] as $error) { print $error . "<br />\n"; } //end foreach } //end if ?></div> <p class="float"> <label for="login"><i class="icon-user"></i>Username</label> <input type="text" id="email" name="email" placeholder="E-mail"> <span class="errorFeedback errorSpan" id="emailError">E-mail is required</span> </p> <p class="float"> <label for="password"><i class="icon-lock"></i>Password</label> <input type="password" id="password" name="password" placeholder="Password" class="showpassword"> <span class="errorFeedback errorSpan" id="passwordError">Password is required</span> </p> <p class="clearfix"> <input type="submit" name="submit" value="Log in"></form> </p> </div> </div> </div> </div> </div>
с<div id="maincontentWrapper"> <div id="maincontent"> <div id="contentWrapper"></div><!--End loginWrapper --> <article> <p>Welcome to iManage, please login in below.</p> </article> <div id="loginform"> <div id="loginWrapper"> <form id="loginForm" method="POST" action="classes/class.Login.php"> <h1><span class="log-in">Log in</span> or <span class="sign-up"><a href="register">sign up</a></span></h1> <div id="errorDiv"><?php if (isset($_SESSION['error']) & isset($_SESSION['formAttempt'])) { unset($_SESSION['formAttempt']); print "Errors encountered<br/>\n"; foreach ($_SESSION['error'] as $error) { print $error . "<br />\n"; } //end foreach } //end if ?></div> <p class="float"> <label for="login"><i class="icon-user"></i>Username</label> <input type="text" id="email" name="email" placeholder="E-mail"> <span class="errorFeedback errorSpan" id="emailError">E-mail is required</span> </p> <p class="float"> <label for="password"><i class="icon-lock"></i>Password</label> <input type="password" id="password" name="password" placeholder="Password" class="showpassword"> <span class="errorFeedback errorSpan" id="passwordError">Password is required</span> </p> <p class="clearfix"> <input type="submit" name="submit" value="Log in"></form> </p> </div> </div> </div> </div> </div>
классы / class.Login.php
<?php include("../connect/class.Connect.php"); class Login extends Database { public $id; public $email; public $username; public function __construct() { if (session_id() == "") { session_start(); } if (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] == true) { $this->_initUser(); } } // end construct public function authenticate($user, $pass) { $safeUser = $this->mysqli->real_escape_string($pass); $query = "SELECT * from users WHERE email = '{$safeUser}'"; if (!$result = $this->mysqli->query($query)) { error_log("Cannot retrieve account for {$user}"); return false; } // will be only one row, so no while() loop needed $row = $result->fetch_assoc(); $dbPassword = $row['password']; if (crypt($incomingPassword,$dbPassword) != $dbPassword) { error_log("Passwords for {$user} don't match"); return false; } $this->id = $row['id']; $this->username = $row['username']; $this->email = $row['email']; $this->isLoggedIn = true; $this->_setSession(); return true; } // end function autheticate private function _setSession() { if (session_id() == '') { session_start(); } $_SESSION['id'] = $this->id; $_SESSION['email'] = $this->email; $_SESSION['username'] = $this->username; $_SESSION['isLoggedIn'] = $this->isLoggedIn; } // end function setSession private function _initUser() { if(session_id() == '') { sessions_start(); } $_SESSION['id'] = $this->id; $_SESSION['email'] = $this->email; $_SESSION['username'] = $this->username; $_SESSION['isLoggedIn'] = $this->isLoggedIn; }// end function initUser function validatelogin () { $_SESSION['formAttempt'] = true; if (isset($_SESSION['error'])) { unset($_SESSION['error']); } $_SESSION['error'] = array(); $required = array("email","password"); //Check required fields foreach ($required as $requiredField) { if (!isset($_POST[$requiredField]) || $_POST[$requiredField] == "") { $_SESSION['error'][] = $requiredField . " is required."; } } if (!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { $_SESSION['error'][] = "Invalid e-mail address"; } if (count($_SESSION['error']) > 0) { die(header("Location: login.php")); } else { $user = new User; if ($user->authenciate($_POST['email'], $_POST['password'])) { unset($_SESSION['formAttempt']); die(header("Location: authenticated.php")); }else { $_SESSION['error'][] = "There was a problem with your username or password."; die(header("Location: login.php")); } } } } $run = new Login(); $run->authenticate($user, $pass); $run->validatelogin(); ?>
в<?php include("../connect/class.Connect.php"); class Login extends Database { public $id; public $email; public $username; public function __construct() { if (session_id() == "") { session_start(); } if (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] == true) { $this->_initUser(); } } // end construct public function authenticate($user, $pass) { $safeUser = $this->mysqli->real_escape_string($pass); $query = "SELECT * from users WHERE email = '{$safeUser}'"; if (!$result = $this->mysqli->query($query)) { error_log("Cannot retrieve account for {$user}"); return false; } // will be only one row, so no while() loop needed $row = $result->fetch_assoc(); $dbPassword = $row['password']; if (crypt($incomingPassword,$dbPassword) != $dbPassword) { error_log("Passwords for {$user} don't match"); return false; } $this->id = $row['id']; $this->username = $row['username']; $this->email = $row['email']; $this->isLoggedIn = true; $this->_setSession(); return true; } // end function autheticate private function _setSession() { if (session_id() == '') { session_start(); } $_SESSION['id'] = $this->id; $_SESSION['email'] = $this->email; $_SESSION['username'] = $this->username; $_SESSION['isLoggedIn'] = $this->isLoggedIn; } // end function setSession private function _initUser() { if(session_id() == '') { sessions_start(); } $_SESSION['id'] = $this->id; $_SESSION['email'] = $this->email; $_SESSION['username'] = $this->username; $_SESSION['isLoggedIn'] = $this->isLoggedIn; }// end function initUser function validatelogin () { $_SESSION['formAttempt'] = true; if (isset($_SESSION['error'])) { unset($_SESSION['error']); } $_SESSION['error'] = array(); $required = array("email","password"); //Check required fields foreach ($required as $requiredField) { if (!isset($_POST[$requiredField]) || $_POST[$requiredField] == "") { $_SESSION['error'][] = $requiredField . " is required."; } } if (!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { $_SESSION['error'][] = "Invalid e-mail address"; } if (count($_SESSION['error']) > 0) { die(header("Location: login.php")); } else { $user = new User; if ($user->authenciate($_POST['email'], $_POST['password'])) { unset($_SESSION['formAttempt']); die(header("Location: authenticated.php")); }else { $_SESSION['error'][] = "There was a problem with your username or password."; die(header("Location: login.php")); } } } } $run = new Login(); $run->authenticate($user, $pass); $run->validatelogin(); ?>
с<?php include("../connect/class.Connect.php"); class Login extends Database { public $id; public $email; public $username; public function __construct() { if (session_id() == "") { session_start(); } if (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] == true) { $this->_initUser(); } } // end construct public function authenticate($user, $pass) { $safeUser = $this->mysqli->real_escape_string($pass); $query = "SELECT * from users WHERE email = '{$safeUser}'"; if (!$result = $this->mysqli->query($query)) { error_log("Cannot retrieve account for {$user}"); return false; } // will be only one row, so no while() loop needed $row = $result->fetch_assoc(); $dbPassword = $row['password']; if (crypt($incomingPassword,$dbPassword) != $dbPassword) { error_log("Passwords for {$user} don't match"); return false; } $this->id = $row['id']; $this->username = $row['username']; $this->email = $row['email']; $this->isLoggedIn = true; $this->_setSession(); return true; } // end function autheticate private function _setSession() { if (session_id() == '') { session_start(); } $_SESSION['id'] = $this->id; $_SESSION['email'] = $this->email; $_SESSION['username'] = $this->username; $_SESSION['isLoggedIn'] = $this->isLoggedIn; } // end function setSession private function _initUser() { if(session_id() == '') { sessions_start(); } $_SESSION['id'] = $this->id; $_SESSION['email'] = $this->email; $_SESSION['username'] = $this->username; $_SESSION['isLoggedIn'] = $this->isLoggedIn; }// end function initUser function validatelogin () { $_SESSION['formAttempt'] = true; if (isset($_SESSION['error'])) { unset($_SESSION['error']); } $_SESSION['error'] = array(); $required = array("email","password"); //Check required fields foreach ($required as $requiredField) { if (!isset($_POST[$requiredField]) || $_POST[$requiredField] == "") { $_SESSION['error'][] = $requiredField . " is required."; } } if (!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { $_SESSION['error'][] = "Invalid e-mail address"; } if (count($_SESSION['error']) > 0) { die(header("Location: login.php")); } else { $user = new User; if ($user->authenciate($_POST['email'], $_POST['password'])) { unset($_SESSION['formAttempt']); die(header("Location: authenticated.php")); }else { $_SESSION['error'][] = "There was a problem with your username or password."; die(header("Location: login.php")); } } } } $run = new Login(); $run->authenticate($user, $pass); $run->validatelogin(); ?>
с<?php include("../connect/class.Connect.php"); class Login extends Database { public $id; public $email; public $username; public function __construct() { if (session_id() == "") { session_start(); } if (isset($_SESSION['isLoggedIn']) && $_SESSION['isLoggedIn'] == true) { $this->_initUser(); } } // end construct public function authenticate($user, $pass) { $safeUser = $this->mysqli->real_escape_string($pass); $query = "SELECT * from users WHERE email = '{$safeUser}'"; if (!$result = $this->mysqli->query($query)) { error_log("Cannot retrieve account for {$user}"); return false; } // will be only one row, so no while() loop needed $row = $result->fetch_assoc(); $dbPassword = $row['password']; if (crypt($incomingPassword,$dbPassword) != $dbPassword) { error_log("Passwords for {$user} don't match"); return false; } $this->id = $row['id']; $this->username = $row['username']; $this->email = $row['email']; $this->isLoggedIn = true; $this->_setSession(); return true; } // end function autheticate private function _setSession() { if (session_id() == '') { session_start(); } $_SESSION['id'] = $this->id; $_SESSION['email'] = $this->email; $_SESSION['username'] = $this->username; $_SESSION['isLoggedIn'] = $this->isLoggedIn; } // end function setSession private function _initUser() { if(session_id() == '') { sessions_start(); } $_SESSION['id'] = $this->id; $_SESSION['email'] = $this->email; $_SESSION['username'] = $this->username; $_SESSION['isLoggedIn'] = $this->isLoggedIn; }// end function initUser function validatelogin () { $_SESSION['formAttempt'] = true; if (isset($_SESSION['error'])) { unset($_SESSION['error']); } $_SESSION['error'] = array(); $required = array("email","password"); //Check required fields foreach ($required as $requiredField) { if (!isset($_POST[$requiredField]) || $_POST[$requiredField] == "") { $_SESSION['error'][] = $requiredField . " is required."; } } if (!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { $_SESSION['error'][] = "Invalid e-mail address"; } if (count($_SESSION['error']) > 0) { die(header("Location: login.php")); } else { $user = new User; if ($user->authenciate($_POST['email'], $_POST['password'])) { unset($_SESSION['formAttempt']); die(header("Location: authenticated.php")); }else { $_SESSION['error'][] = "There was a problem with your username or password."; die(header("Location: login.php")); } } } } $run = new Login(); $run->authenticate($user, $pass); $run->validatelogin(); ?>
prepend.php
<?php if (!isset($_SESSION) ) { session_start(); } ?>
.htaccess
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php php_value auto_prepend_file "prepend.php"