使用PHP制作 简易员工管理系统之三(管理员登陆界面以及数据库验证)

来源:互联网 发布:定时自动打电话软件 编辑:程序博客网 时间:2024/05/16 16:56

一、修改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();    } */?>
0 0
原创粉丝点击