一、sql 语句就有问题了。既然向PHP端传入参数name和password,那么$sql 就得做出更改了。
$sql = "select * from admin where name='".$name."' and password='".md5($password)."'"
二、函数mysqli_fetch_assoc() 函数从结果集中取得一行作为关联数组。while只针对二维数组来循环 *** 作的,所以$row=mysqli_fetch_assoc($result)即可。
所以整体代码更改如下:
$sql=""if (!isset($_POST) || empty($_POST)) {
} else {
//关联数据库接受信息
$name = $_POST['name']
$password = $_POST['password']
$sql = "select * from admin where name='".$name."' and password='".md5($password)."'"
if ( $result=mysqli_query($con,$sql) )
{
$row = mysqli_fetch_assoc($result)
mysqli_free_result($result)// 释放结果集
if($row){
header("Location:empManage.php")
exit()
}else{
header("Location:login.php?errno=1")
exit()
}
}else{
echo("错误描述: " . mysqli_error($con))
}
mysqli_close($conn)
}
if (rst.next()) {response.sendRedirect("login_in.jsp")
}
else {
response.sendRedirect("error.jsp")
} //三个页面放到同一目录就行
异常捕获try {
//数据库 *** 作
}catch(Exception e){
//这里捕获到数据库 *** 作错误
//重定向(转发也可以)跳转页面
response.sendRedirect("error.jsp")
return
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)