我尋路錯誤:憋屈一個奇怪的尋路錯誤
Warning: require_once(test/assets/includes/memberfunc.php): failed to open stream: No such file or directory in C:\xampp\htdocs\test\assets\includes\logininc.php on line 4
Fatal error: require_once(): Failed opening required 'test/assets/includes/memberfunc.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\test\assets\includes\logininc.php on line 4
然而,我的路徑是正確的。基目錄是測試。測試是我所有網頁的位置。在上面是assets/includes/logininc.php和assets/configs/db_config.php。一切都應該是正確的。請指教
這是我最簡單的形式,在測試稱爲login.php中坐鎮。
<form id="login-form" method="post" action="assets/includes/logininc.php"> <fieldset>
<legend>Login </legend>
<p>Please enter your username and password to access the administrator's panel</p>
<label for="username"> <input type="text" name="username" id="username" />Username: </label> <label for="password"> <input type="password" name="password" id="password" />Password: </label> <label for="submit"> <input type="submit" name="submit" id="submit" value="Login" /> </label> </fieldset> </form>
這反過來又引導我到下面的文件。 Logininc.php。它位於assets/includes/logininc.php
<?php
require_once("/test/assets/includes/memberfunc.php"); //LINE 4
require_once("/test/assets/config/db_config.php");
session_start();
if($_SESSION['logged_in'] ==true) {
redirect('/test/index.php');
echo "success";
}
else{
if ((!isset($_POST['username'])) || (!isset($_POST['password'])) or
(!ctype_alnum($_POST['username'])))
redirect("/test/login.php");
}
$mysqli = @new mysqli(HOST, NAME, PW, DB);
//check connection
if(mysqli_connect_errorno())
{
printf("Unable to connect to DB! : %s",
mysqli_connect_error());
exit();
}
//Escape unsafe chars
$username = $mysqli->real_escape_string($_POST['username']);
$username = $mysqli->real_escape_string($_POST['password']);
//Time to make a SQL Q for execution
$sql = "SELECT * FROM users WHERE username= '".$username . "'AND password = '" . md5($password) . "'";
$result = $mysqli->query($sql);
// If one row is returned, USER AND PW is valid!
if (is_object($result) && $result->num_rows == 1) {
//set session variable for login true
$_SESSION['logged_in'] = true;
redirect('../../index.php');
}
else{ //if number of rows is not one redirect back to login
redirect('../../login.php');
}
?>
。
請指教。
嘗試'require_once(「memberfunc.php」);' –
在您的assets \ includes/logininc.php文件中的php開始標記後面執行'print getcwd();'以確保路徑,因爲這幾乎肯定是這樣。 –
@koala_dev試過了,但後來我得到完全相同的錯誤DB_CONFIG。也嘗試過你的建議,但沒有明確。丹尼爾菲格羅亞嘗試了你的建議,但似乎我對自己的道路是正確的?回聲= C:\ XAMPP \ htdocs中\測試\資產\包括 –