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 "删除失败";
    }
  • 相关阅读:
    Hostker云主机
    Orz 终于有了自己的博客地址
    BZOJ 1635: [Usaco2007 Jan]Tallest Cow 最高的牛
    BZOJ 1636: [Usaco2007 Jan]Balanced Lineup
    BZOJ 2252: [2010Beijing wc]矩阵距离
    BZOJ 2253: [2010 Beijing wc]纸箱堆叠
    BZOJ 无数据题集合
    BZOJ 1087: [SCOI2005]互不侵犯King
    BZOJ 3236: [Ahoi2013]作业
    POJ2352:Stars
  • 原文地址:https://www.cnblogs.com/jc535201285/p/6416183.html
Copyright © 2011-2022 走看看