zoukankan      html  css  js  c++  java
  • 登录主页面代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    
    <body>
    
    <h1>登录页面</h1>
    
    <form action="chuli.php" method="post">
    <div>用户名:<input type="text" name="uid" /></div>
    <div>密码:<input type="password" name="pwd" /></div>
    <div><input type="submit" value="登录" /></div>
    </form>
    
    </body>
    </html>
    <?php
    $uid = $_POST["uid"];
    $pwd = $_POST["pwd"];
    
    $db = new MySQLi("localhost","root","123","mydb");
    
    $sql = "select pwd from users where uid='{$uid}'";
    $result = $db->query($sql);
    
    $a = $result->fetch_row();
    
    if(!empty($pwd) && $a[0]==$pwd)
    {
        //跳转页面
        //header("location:main.php");
        echo "<script>window.location = 'main.php';</script>";
    }
    else
    {
        echo "用户名或密码错误!";
    }
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    
    <body>
    
    <h1>人员列表</h1>
    
    <table width="100%" border="1" cellpadding="0" cellspacing="0">
        <tr>
            <td>代号</td>
            <td>姓名</td>
            <td>性别</td>
            <td>民族</td>
            <td>生日</td>
            <td>操作</td>
        </tr>
        
        <?php
        $db = new MySQLi("localhost","root","123","mydb");
        $sql = "select * from info";
        $result = $db->query($sql);
        
        if($result)
        {
            while($attr = $result->fetch_row())
            {
                //对性别进行了处理
                $sex = $attr[2]?"男":"女";
                
                //对民族进行处理
                $sname = "select name from nation where code='{$attr[3]}'";
                $nresult = $db->query($sname);
                $aname = $nresult->fetch_row();
                $nation = $aname[0];
                
                
                echo "<tr>
            <td>{$attr[0]}</td>
            <td>{$attr[1]}</td>
            <td>{$sex}</td>
            <td>{$nation}</td>
            <td>{$attr[4]}</td>
            <td><a onclick="return confirm('确定要删除么?')" href='shanchu.php?code={$attr[0]}'>删除</a></td>
        </tr>";
            }
        }
        
        ?>
        
    </table>
    
    </body>
    
    </html>
    <?php
    
    $code = $_GET["code"];
    
    $db = new MySQLi("localhost","root","123","mydb");
    $sql = "delete from info where code='{$code}'";
    
    if($db->query($sql))
    {
        header("location:main.php");
    }
    else
    {
        echo "删除失败";
    }
  • 相关阅读:
    2014第8周二杂记
    2014第8周一JS正则小问题
    2014第7周日最强大脑
    2014第7周六杂记
    2014第7周五杂记
    2014第7周四excel多列文本复制技巧
    2014第7周三初识CouchBase
    2014第7周二需求
    2014第7周1Web安全概念学习
    shell程序之逐行读取一文件里的參数且使用此參数每次运行5分钟
  • 原文地址:https://www.cnblogs.com/jc535201285/p/6416183.html
Copyright © 2011-2022 走看看