<?php include "../common/dbsession.php";會話開始(); if(isset($_SESSION['user'])){ header('location:../content/home.php'); }else{ if(isset($_POST['vcode'])){ if($_POST['vcode']==$_SESSION[' $conn=mysqli_connect("10.21 .54.99:3306","c322","20210409","c322"); $sql="select * from `user` where `email`='".$_POST['zh']."'"; $res=mysqli_query($conn,$sql); mysqli_fetch_array($res); /*if (!$res){ printf("錯誤:%s\n", mysqli_error($conn));出口(); }*/ $row=mysqli_fetch_assoc($res); if(!$conn){ die("連線失敗".mysqli_connect_error()); } //var_dump($res); if(isset($row['pw'])){//表中 if(md5($_POST['pw'])==$row['p $_SESSION['用戶']=$_POST['zh']; //登陸成功 echo "3"; }else{ echo "0";//帳戶密碼錯誤 echo "2";//帳戶不存在 } //session_destroy (); } 出口; } }?><!doctype html><html> <head> <title>使用者登入</title> <meta charset="utf-8"> <meta charset=" src="../resource/jquery-3.2.1.min.js"></script> <link rel="style.css" href="../login.css"> </ head> <body> <div style="text-align:center;margin-top:20px;"> <div>歡迎登陸</div>Š <div>歡迎登陸</div> meth1 > <img src="../resource/kcaptcha/index。 /div> <div> <input type="text" class="zh" placeholder="請輸入為帳號的信箱"> & lt divholder="請輸入為帳號的信箱"> <input type="password" class ="pw" placeholder="請輸入密碼" autocomplete="off" > </div> <div> <input </div> </form> <script> function login(){ ./login.php", {"vcode":$(".vcode").val(), ".zh").val(), "pw":$(".pw").val()}, alert(res); if(res==0){ ="../content/home.php"; }else if(res==1){ 錯誤之後使用) 錯誤驗證; }else if(res==2){ alert("帳號輸入錯誤,請重新輸入!"); }else if(res==3){ }else{ alert("服務例外中,請更新頁面重試或聯絡管理員!") } } } </script> </body></html>
autoload2021-11-29 10:48:25
if (!$res) { printf("Error: %s\n", mysqli_error($conn)); exit(); }
這個語句不要註釋,看看是mysqli_fetch_assoc()參數問題,還是sql語句問題