我有路径错误:
警告:require_once(test/assets/includes/memberfunc.php):无法打开流:第 4 行的 C:\xampp\htdocs\test\assets\includes\logininc.php 中没有这样的文件或目录
致命错误:require_once():在 C:\xampp\htdocs\test\assets\includes 中打开所需的 'test/assets/includes/memberfunc.php' (include_path='.;C:\xampp\php\PEAR') 失败\logininc.php 在第 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>
这反过来又将我引导到下面的文件。登录inc.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');
}
?>
.
请指教。