时间:2021-07-01 10:21:17 帮助过:32人阅读
loginprocess.php源代码如下:
1 <?php 2 ////设置php文件的编码 3 header("Content-type:text/html;charset=utf-8"); 4 //接受用户数据 5 $id=$_POST[‘id‘]; 6 $password=$_POST[‘password‘]; 7 //得到连接 8 $conn=mysql_connect("localhost","root","root"); 9 if (!$conn) { 10 die("连接失败!错误信息:".mysql_errno()); 11 } 12 //设置访问数据库的编码 13 mysql_query("set names utf8",$conn) or die("设置编码失败!错误信息:".mysql_errno()); 14 //选择数据库 15 mysql_select_db("aedb",$conn) or die("选择数据库失败!错误信息:".mysql_errno()); 16 //发送SQL语句 17 $sql="SELECT password FROM ad WHERE id=$id"; 18 //获取查询结果集 19 $res=mysql_query($sql,$conn); 20 //判断查询结果是否存在及是否完全匹配 21 //md5(),计算机安全领域广泛使用的一种散列函数,用以提供消息的完整性保护。 22 if (($row=mysql_fetch_assoc($res)) && $row[‘password‘]==md5($password)) { 23 //匹配成功,跳转到mainview.php 24 header("Location:mainview.php"); 25 die(); 26 } 27 //匹配失败,跳转到loginview.php,并发送错误信息error 28 header("Location:loginview.php?error=1"); 29 die(); 30 ?>loginprocess.php
mainview.php源代码如下:
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>欢迎使用雇员信息管理系统</title> 5 <meta http-equiv = "content-type" content="text/html; charset = utf-8 "> 6 7 <style type="text/css"> 8 div.d0{color:red; size:200px; font-weight:700;text-align:center;} 9 </style> 10 11 </head> 12 <body bgcolor="#ABC" > 13 <div class="d0">登录成功!!</div> 14 </body> 15 </html>mainview.php
雇员信息管理系统(2)管理员数据库登录
标签:消息 php 账号密码 显示 img 表单 sse width 需要