嗨,我想創建一個非常簡單的日誌功能使用PHP然而,通過代碼去後,我的狀態似乎能夠正確,只有當我輸入正確的用戶名執行的功能和設置密碼,如果我不,它並不在這裏履行職責,是我的,我已經簡化代碼:登錄找不到錯誤
的login.php
<form name="userlogin" action="phpprocess/loginprocess.php" method="POST">
<p>Username : <input type="text" id="username" name="username"></p>
<p>Password : <input type="password" id="password" name="password"></p>
<p><input type="submit" id="loginbtn" value="login" ></p>
</form>
loginproccess.php
include "mysqli.connect.php";
$username = $mysqli->real_escape_string($_REQUEST["username"]);
$password = $mysqli->real_escape_string($_REQUEST["password"]);
echo "$username";
echo "$password";
$sql = "select * from users.userlogin where username ='".$username."' and
password = '".$password."'";
$result = $mysqli->query($sql);
if($result == null){
echo"null";
}
if($mysqli -> errno){
error_log($mysqli -> error);
echo $mysqli -> error;
echo " hello";
exit();
}else{
while(list($index, $user1, $pass1) = $result -> fetch_array()){
if($user1 != null && $pass1 != null){
echo "$index $user1, $pass1";
}
}
}
$mysqli->close();
mysqli.c onnect.php
$host="localhost";
$user="root";
$password="";
$database="users";
$mysqli = new mysqli($host, $user, $password, $database);
if ($mysqli->errno) {
echo "Unable to connect to the database: <br />".$mysqli->error;
exit();
}
發生的事情是,如果我輸入了錯誤的用戶名和密碼,我需要的網頁呼應你好,如果我輸入正確我需要它呼應了正確的用戶,並通過但當輸入錯誤, $結果看起來不是null,因爲null和hello沒有被打印出來。我的錯誤日誌不顯示任何內容。希望聽到您的建議!先謝謝你 !
哎barmar!感謝您的支持!它真的很有用,因爲我自己學習PHP!謝謝你,生病了:) –