使用PHP制作 简易员工管理系统之三(管理员登陆界面以及数据库验证)
2015-06-02 16:38
831 查看
一、修改login.Process.php
<meta http-equiv="content-type" content="text/html;charset=utf-8"/> <?php //接受用户的数据 //1.id $id = $_POST['id']; //2.密码 $password = $_POST['password']; //3.数据库验证 $conn = mysql_connect("localhost","root",159357); if(!$conn){ die("连接失败!".mysql_errno()); } //设置数据库的编码 mysql_query("set names utf8",$conn) or die(mysql_errno()); //选择数据库 mysql_select_db("usersDb",$conn) or die(mysql_errno()); //发送sql数据库,验证 //需要防止sql注入攻击 //$sql = "select * from admin where id=$id and password='$password'"; //通过输入的id号获取数据库中的密码 然后再 和输入的密码比对 $sql = "select password from admin where id = $id"; $res = mysql_query($sql,$conn); if ($row = mysql_fetch_assoc($res)) { //查询到数据库密码 if ($row['password'] == md5($password)) { header("Location: erpManager.php"); exit(); return; }; } header("Location: login.php?error=1&id=$id&password=$password"); exit(); //关闭资源 mysql_free_result($res); mysql_close($conn); //3.简单验证 /* if ($id == "1000" && $password == "123") { //合法,跳转到erpManager.php header("Location: erpManager.php"); exit(); }else{ //非法 header("Location: login.php?error=1&id=$id&password=$password"); exit(); } */ ?>
相关文章推荐
- PHP正则表达式报错分析
- windows下PHP不能开启pgsql扩展的解决方法
- php学习随记3
- 关于stdClass
- PHP Cookie与Session的使用与区别
- php使用GD实现颜色渐变实例
- PHP准确取得服务器IP地址的方法
- 解决RadioButton+FragmentPagerAdapter+Fragment切换页面数据加载的问题
- 使用PHP制作 简易员工管理系统之二(管理员登陆界面以及验证)
- PHP中isset与array_key_exists的区别实例分析
- ThinkPHP开发笔记-前后端数据交互
- 浅述php的socket通信原理
- ESXI5.5设置主机的时间自动同步服务 NTP
- [PHP问题]Cannot redeclare xxxxxx() (previously declared in C:\WWW\xxx.xxx:xxx)
- ORTP库的使用
- ORTP中的API函数说明
- php 蒋中文首字母转换成拼音
- PHP时间
- php学习笔记之动态生成一组单选按钮
- MTP