<?php include "../common/dbsession.php"; session_start(); if(isset($_SESSION['user'])){ header('location:../content/home.php'); }else{ if(isset($_POST['vcode'])){ if($_POST['vcode']==$_SESSION['vcode']){ //核对数据表user $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("Fehler: %sn", mysqli_error($conn)); Ausfahrt(); }*/ $row=mysqli_fetch_assoc($res); if(!$conn){ die("连接失败".mysqli_connect_error()); } //var_dump($res); if(isset($row['pw'])){//表中存在 if(md5($_POST['pw'])==$row['pw']){ $_SESSION=[]; $_SESSION['user']=$_POST['zh']; //登陆成功 echo "3"; }else{ echo "0";//账户密码错误 }else{ //表中不存在 echo "2";//账户不存在 } echo "1";//验证码不对 //session_destroy (); } Ausfahrt; } }?><!doctype html><html> <title>Benutzeranmeldung</title> <script type="text/javascript" src ="../resource/jquery-3.2.1.min.js"></script> <link rel="style.css" href="../login.css"> ; <body> <div style="text-align:center;margin-top:20px;">Willkommen beim Anmelden <form action='' method='post' > </div> </form> (".vcode").val(), "zh":$( ".zh").val(), "pw":$(".pw").val()}, function(res){ Alert(res); if(res==0){ window.location.href = "../ Content/Home.php";} Else if (res == 1) {alert ("Bestätigungscode Eingabefehler, bitte eintreten! "); falsche Kontoeingabe, bitte eintreten!"); /html>
这个语句不要注释,看看是mysqli_fetch_assoc()参数问题,还是sql语句问题