<?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']){? ? ? ? ? ? ? ? //核對(duì)數(shù)據(jù)表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("Error: %s\n", mysqli_error($conn)); exit(); }*/? ? ? ? ? ? ? ? $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";//賬戶(hù)密碼錯(cuò)誤?? ? ? ? ? ? ? ? ? ?}? ? ? ? ? ? ? ? }else{ //表中不存在? ? ? ? ? ? ? ? ? ? echo "2";//賬戶(hù)不存在? ? ? ? ? ? ? ??? ? ? ? ? ? ? ? }? ? ? ? ? ? }else{? ? ? ? ? ? ? echo "1";//驗(yàn)證碼不對(duì)? ? ? ? ? ? ? //session_destroy();? ? ? ? ? ? }? ? ? ? exit;? ? ? }? ? }?><!doctype html><html> <head> <title>User login</title> <meta charset="utf-8"> <script type="text/javascript" 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>Welcome to log in</div> <form action='' method='post' >??????????????????????????????????????????????????????????????/div> ="pw" placeholder="Please enter password" autocomplete="off" > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?</div> </form> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?".vcode").val(), "zh":$( ".zh").val(), "pw":$(".pw").val()}, function(res){ alert(res); alert(res); if(res==0){ window.location.href "../content/home.php"; alert(" Account input error, please re -enter! ");} Else if (res == 3) {alert (" Account password input error, please re -enter! "); Or contact the administrator!") ?????????????????????????????????????????????????????????????????????????????????????????????????????????lt;/body></html>
if?(!$res)?{?? ??printf("Error:?%s\n",?mysqli_error($conn));???? ??exit(); ??}
Do not comment this statement to see if it is a mysqli_fetch_assoc() parameter problem or a sql statement problem