<?php require_once '../include.php'; $username=$_POST['username']; $password=md5($_POST['password']); $verify=$_POST['verify']; $verify1=$_SESSION['verify']; if($verify==$verify1){ $sql="select * from imooc_admin where username='{$username}' and password='{$password}'"; $row=checkAdmin($sql); var_dump($row); if($row){ $_SESSION['adminName']=$row['username']; //header("location:index.php"); //alertMes("登陆成功","index.php"); }else{ //alertMes("登陆失败,重新登录","login.php"); } }else{ alertMes("验证码错误,重新登录","login.php"); } ?> // checkAdmin()的代码。 <?php /** * 检查管理员是否存在 * @param unknown_type $sql * @return Ambigous <multitype:, multitype:> */ function checkAdmin($sql){ return fetchOne($sql); } ?> //这是fetchOne的代码 function fetchOne ($sql,$result_type=MYSQLI_ASSOC) { $link = connect(); $result = mysqli_query($link,$sql); if (mysqli_errno($link)){ die(mysqli_errno($link)); $mes = mysqli_errno($link); echo "<script>alert('{$mes}');</script>"; } $row = mysqli_fetch_array($result); return $row; } //如果是测试var_dump($sql);可以得到username和password可是var_dump($row)就只有null。
慕的地6079101
野生码农在线co腚
ALEX3403648
林逸舟丶
CodeManDSH