doLogin中不管加不加密返回值均为NULL
下面是我的部分代码:
function fetchOne($sql,$result_type=MYSQLI_ASSOC){//ASSOC返回关联词组
$link=mysqli_connect(DB_HOST,DB_USER,DB_PWD) or die("数据库链接失败Error:".mysqli_errno().":".mysqli_errno());
mysqli_set_charset($link,DB_CHARSET);
mysqli_select_db($link,DB_DBNAME) or die("指定数据库打开失败");
$result=mysqli_query($link,$sql);
if (!$result) {
//return bace;
printf("Error: %s\n", mysqli_error($link));
exit();
}
$row=mysqli_fetch_array($result,$result_type);
return $row;
}
<?php
require_once '../include.php';
$username=$_POST['username'];
$password=$_POST['password'];
//$password=md5($_POST['password']);
$verify=$_POST['verify'];
$verify1=$_SESSION['verify'];
//$autoFlag=$_POST['autoFlag'];
if($verify==$verify1){
$sql="select * from MFY_admin where username='{$username}' and password='{$password}'";
/* $row=checkAdmin($sql);
var_dump($row); */
$res = checkAdmin($sql);
var_dump($res);
// if($row){
//如果选了一周内自动登陆
/* if($autoFlag){
setcookie("adminId",$row['id'],time()+7*24*3600);
setcookie("adminName",$row["username"],time()+7*24*3600);
} */
/* $_SESSION['adminName']=$row['username'];
$_SESSION['adminId']=$row['id'];
alertMes("登陆成功", "index.php");
}else{
alertMes("登陆失败,重新登陆", "login.php");
} */
}else{
alertMes("验证码错误,重新登陆", "login.php");
}