• 6.21留言板


    <!DOCTYPE html>
    <html lang="zh">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <link rel="stylesheet" type="text/css" href="../0614/public/bootstrap/css/bootstrap.min.css"/>
        <script src="../0613/public/jquery/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../0614/public/bootstrap/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
        <title>Document</title>
    </head>
    <body>
        开发区内部留言板
        <div>帐号:<input type="text" id="uid" onblur="zhuce()"></div>
        <div>口令:<input type="text" id="pwd"></div>
        <input type="submit" value="登陆"  onclick="denglu()"><input type="submit" value="注册" >
    </body>
    </html>
    <script type="text/javascript">
        function denglu(){
            var uid =document.getElementById("uid").value;
            var pwd =document.getElementById("pwd").value;
            $.ajax({
                type:"post",
                url:"lycl.php",
                async:true,
                data:{
                    type:"denglu",
                    uid:uid,
                    pwd:pwd
                },
                dataType:"text",
                success:function(data){
                    if(data=="ok"){
                        window.location.href = "main.php";
                    }
                    else if(data=="no"){
                        alert("输入有误");
                    }
                }
                
                
            });
        }
        function zhuce(){
            var uid =document.getElementById("uid").value;
            var pwd =document.getElementById("pwd").value;
            $.ajax({
                type:"post",
                url:"lycl.php",
                async:true,
                data:{
                    type:"zhuce",
                    uid:uid,
                    pwd:pwd
                },
                dataType:"text",
                success:function(data){
                    if(data=="cf"){
                        alert("注册名重复");
                    }
    <?php
        session_start();
        if(empty($_SESSION["uid"]))
        {
            header("location:liuyan.php");    
            exit;
        }
    ?>
    <!DOCTYPE html>
    <html lang="zh">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <link rel="stylesheet" type="text/css" href="../0614/public/bootstrap/css/bootstrap.min.css"/>
        <script src="../0613/public/jquery/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="../0614/public/bootstrap/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
        <title>Document</title>
        <style type="text/css">
            *{
                margin: 0px auto;
                padding: 0px;
            }
            .title{
                width: 1260px;
                border: 1px solid gray;
            }
            .title_box{
                height: 100px;
                font-size: 28px;
                text-align: left;
                line-height: 100px;
                margin-left: 20px;
                border: 1px solid gray;
            }
            .nav{
                width: 1260px;
                border: 1px solid gray;
            }
            .nav_box{
                width: 500px;
                height: 50px;
                margin-left: 20px;
                border: 1px solid gray;
            }
            .nav_but{
                width: 100px;
                height: 30px;
                margin-top: 10px;
                float: left;
                line-height: 30px;
                text-align: center;
                margin-right: 20px;
                border: 1px solid gray;
            }
            .nav_but:hover{
                cursor: pointer;
            }
            .nav_text{
                height: 30px;
                margin-top: 10px;
                float: left;
                line-height: 30px;
            }
            .room{
                width: 1260px;
                height: 450px;
                border: 1px solid gray;
            }
            .room_boxa{
                width: 200px;
                height: 450px;
                margin-left: 20px;
                float: left;
                border: 1px solid gray;
            }
            .room_but{
                width: 100px;
                height: 30px;
                margin-top: 10px;
                line-height: 30px;
                text-align: center;
                border: 1px solid gray;
            }
            .room_but:hover{
                cursor: pointer;
            }
            .room_boxb{
                width: 1000px;
                height: 450px;
                margin-left: 20px;
                float: left;
                border: 1px solid gray;
            }
        
            .table{
                border: 1px solid gray;
            }
            #fybut{
                font-size: 18px;
                text-align: center;
            }
            #fybut:hover{
                cursor: pointer;
            }
            .room_room{
                height: 360px;
            }
        </style>
    </head>
    <body>
        <div class="title">
            <div class="title_box">
                开发部内部留言板
            </div>
        </div>
        <div class="nav">
            <div class="nav_box">
                <div class="nav_but">返回首页</div>
                <div class="nav_but" onclick="zhuxiao()">退出系统</div>
                <div class="nav_text"><?php echo $_SESSION["uid"];?> 欢迎您登陆本系统</div>
            </div>
        </div>
        <div class="room">
            <div class="room_boxa">
                <div class="room_but" class="btn btn-primary" data-toggle="modal" data-target="#myModal">发布信息</div>
                <div class="room_but" onclick="chakan()">查看信息</div>
                <div class="room_but" onclick="zhuxiao()">注销</div>
            </div>
            <div class="room_boxb">
                <div class="room_room">
                    <table class="room_count table">
                    
                    </table>
                </div>
                
            </div>
        </div>
        <!--================模态框============-->
    <!-- 模态框 -->
    <div class="modal fade" id="myModal">
      <div class="modal-dialog">
        <div class="modal-content">
     
          <!-- 模态框头部 -->
          <div class="modal-header">
            <h4 class="modal-title">模态框头部</h4>
            <button type="button" class="close" data-dismiss="modal">&times;</button>
          </div>
     
          <!-- 模态框主体 -->
          <div class="modal-body">
            
            <h1>信息发送</h1>
            <table width="300" border="1" bordercolor="#0033CC" cellpadding="1" cellspacing="1">
            <tr><td align="right" width="200">接收人:</td>
               <td>
               <select id="rec">
               <option  value="all">所有人</option>
              <?php
             $conn = new mysqli("localhost","root","","ceshi2");
             $conn->connect_error?die("链接失败"):"";
             $uid = $_SESSION["uid"];
             $sql = "select a.Name,b.friend from yuangong as a,friend as b where a.UserName = b.friend and b.me='{$uid}'";
             $r = $conn->query($sql);
             $attr1=$r->fetch_all();
             for($i=0;$i<count($attr1);$i++){
             echo "<option value='{$attr1[$i][1]}'>{$attr1[$i][0]}</option>";
             }
             ?>
               </select>
               </td>
            </tr>
            <tr><td align="right">信息内容:</td><td><textarea  id="com"></textarea></td></tr>
            </table>
          </div>
     
          <!-- 模态框底部 -->
          <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="fabu()">发布</button>
          </div>
     
        </div>
      </div>
    </div>
    </body>
    </html>
    <script type="text/javascript">
        var tab =document.getElementsByTagName("table")[0];
        function chakan() {
            $.ajax({
                type:"post",
                url:"lycl.php",
                async:true,
                data:{
                    type:"chakan"
                },
                dataType:"json",
                success:function(data){
                    var str = "";
                    str +="<td>序号</td><td>发送人</td><td>接收人</td><td>时间</td><td>内容</td><td>states</td>";
                    for(i=0;i<data.length;i++){
                        str+="<tr>";
                        for(j=0;j<data[i].length;j++){
                            str+="<td>"+data[i][j]+"</td>";
                            }    
                        str+="</tr>";    
                            }
                    tab.innerHTML= str;
                }
            });
        }
        function fabu(){
            var rec = document.getElementById("rec").value
            var com = document.getElementById("com").value;
            $.ajax({
                type:"post",
                url:"lycl.php",
                async:true,
                data:{
                    type:"fabu",
                    rec:rec,
                    com:com
                },
                dataType:"text",
                success:function(data){
                    if(data.trim()=="ok"){
                        alert("发布成功");
                    }
                }
            });
        }
        function zhuxiao() {
            $.ajax({
                type:"post",
                url:"lycl.php",
                async:true,
                data:{
                    type:"zhuxiao"
                },
                dataType:"text",
                success:function(data){
                window.location.href = "liuyan.php";
                }
            });
        }
    </script>
    <?php
        session_start();
        $type = $_POST['type'];
        $conn = new mysqli("localhost","root","","ceshi2");
        $conn->connect_error?die("链接失败"):"";
        switch($type){
            case "denglu":
            $uid = $_POST["uid"];
            $pwd = $_POST["pwd"];
            $sql = "select * from yuangong where UserName = '{$uid}' and PassWord = '{$pwd}'";
            $result=$conn->query($sql);
            $attr=$result->fetch_all();
            if($attr != null){
                $_SESSION["uid"] = $uid; 
                echo "ok";
                }
                else if($attr == null){
                    echo "no";
                };  
            break;
            case "chakan":
            $uid = $_SESSION["uid"];
            $sql = "select * from liuyan where Recever = '{$uid}' or Recever='all'" ;
            $result = $conn->query($sql);
            $attr = $result->fetch_all();
            echo json_encode($attr);
            break;
            
            case "zhuxiao":
            session_destroy(); 
            break;
            
            case "zhuce":
            $uid = $_POST["uid"];
            $sql ="select username from yuangong where username='{$uid}'";
            $result = $conn->query($sql);
            $attr = $result->fetch_row();
            if($attr != null){
                echo "cf";
            };
            break;
            
             
            case "fabu":
            $sender = $_SESSION["uid"];
            $rec = $_POST["rec"];
            $com = $_POST["com"];
            $time = date("Y-m-d H:i:s",time()); 
            $sql = "insert into LiuYan values('','{$sender}','{$rec}','{$time}','{$com}','')";     
            if($result = $conn->query($sql)){
                     echo "ok";
            }
            break;
            
        }
        
        
    ?>
  • 相关阅读:
    Jquery 判断值是否存在于数组之内
    Linux 拷贝有更改的文件
    Thinkphp [美味]常用代码
    Oracle基础知识:DECODE、NVL
    安装配置svn
    搭建LAMP环境以及shell脚本搭建(yum安装)
    Jmeter接口测试webservice
    Jmeter插件安装和使用
    Jmeter中java接口测试
    Jmeter中聚合报告吞吐量的计算
  • 原文地址:https://www.cnblogs.com/sunhao1987/p/9210861.html
Copyright © 2020-2023  润新知