zoukankan      html  css  js  c++  java
  • 留言板

    本软件是作为部门内员工之间留言及发送消息使用。

    系统必须通过口令验证,登录进入。方法是从数据库内取出用户姓名和口令的数据进行校验。

    系统包含四部分功能

    1 登录:验证用户名与口令,保存会话信息,进入主界面。

    界面显示代码

    <title>登录</title>
    </head>
    
    <body>
    <h1>内部留言板登录</h1>
    <form action="logincl.php" method="post">
      <div>账户名:<input type="text" name="uname"/></div>
      <br />
      <div>密  码:<input type="text" name="pwd"/></div>  <br />
      <div>        
           <input type="submit" value="登录"/></div>
      <br />
    </form>
    </body>
    </html>
    

      

    登录后台处理代码:logincl.php

    <?php
    session_start();//启动session
     
    include("DBDA.class.php");
    $db=new DBDA();
     
    $uname=$_POST["uname"];
    $pwd=$_POST["pwd"];
     
    $sql="select count(*) from yuangong where username='{$uname}' and password='{$pwd}'";
     
    $re=$db->StrQuery($sql);
     
    if($re==1)
    {
    	$sql2="select name from yuangong where username='{$uname}' and password='{$pwd}'";
    	$attr=$db->Query($sql2);
        $_SESSION["name"]=$attr[0][0];   //服务器记录session
        header("location:liuyan.php");
    }
    else
    {
        header("location:login.php");
    }
    

      

    2 信息查询:显示给当前登录人留的信息以及公共信息(给所有人发送)。

    留言信息界面显示代码

    <title>留言信息</title>
    <style type="text/css">
    #two
    {
    	1000px;
    	height:800px;
    	background-color:#9FC;
    	margin-top:100px;
    	margin-left:200px;
    }
    #three
    {
    	margin:0;
    	padding:0;
    	float:left;
    	color:#06F;
    }
    #four
    {
    	margin:0;
    	padding:0;
    	float:right;
    	color:#06F;
    }
    #five
    {
    	margin:0;
    	padding:0;
    	float:right;
    	color:#06F;
    }
    </style>
    </head>
    
    <body>
    <?php
    session_start();
    
    if(empty($_SESSION["name"]))
    {
        header("location:login.php");
    }
    
    ?>
    
      <div id="two">
        <div id="three"><a href="fabu.php">发布信息</a></div>
        <div id="four"><a href="tuichu.php">退出系统</a></div>
        <div id="five"><?php echo $_SESSION["name"];?>    </div>
        <br />
        <table width="600px" border="1" cellpadding="0" cellspacing="0" align="center">
        <caption><h2>留言信息</h2></caption>
        <tr align="center">
            <td>发送人</td>
            <td>发送时间</td>
            <td>接收人</td>
            <td>信息内容</td>
        </tr>
        
        <?php
        include("DBDA.class.php");
    	$db=new DBDA();
    	
    	$name=$_SESSION["name"];
    	
    	$sql="select * from liuyan where recever in ('{$name}','所有人')";
    	$attr=$db->Query($sql);
    	
    	foreach($attr as $v)
    	{
    		echo "<tr align='center'>
    		      <td>{$v[1]}</td>
    			  <td>{$v[3]}</td>
    			  <td>{$v[2]}</td>
    			  <td>{$v[4]}</td>
    			  </tr>";
    	}
    	?>
        
        </table>
      </div>
    
    </body>
    </html>
    

      

    3 发信息:当前登录人员用来给其他人发信息的功能。信息的内容包括:信息的编号(自动编号),发送人,信息内容,接收人,发送时间等,可以发给所有人,也可以发给某个人

    <title>发布信息</title>
    <style type="text/css"> #two { 1000px; height:800px; background-color:#9FC; margin-top:100px; margin-left:200px; } #three { margin:0; padding:0; float:left; color:#06F; } #four { margin:0; padding:0; float:right; color:#06F; } #five { margin:0; padding:0; float:right; color:#06F; } #six { } </style> </head> <body> <?php session_start(); if(empty($_SESSION["name"])) { header("location:login.php"); } ?> <div id="two"> <div id="three"><a href="liuyan.php">查看信息</a></div> <div id="four"><a href="tuichu.php">退出系统</a></div> <div id="five"><?php echo $_SESSION["name"];?>    </div> <br /> <table align="center" width="600" border="0" cellpadding="0" cellspacing="0"> <caption><h2>信息发送</h2></caption> <tr align="center"><td> <form action="fabucl.php" method="post"> <div>接 收 人: <select name="recever" size="1"> <option value="所有人">所有人</option> <?php include("DBDA.class.php"); $db=new DBDA(); $me=$_SESSION["name"]; $sql="select firend from friend where me='{$me}'"; $attr=$db->Query($sql); foreach($attr as $v) { echo "<option value='{$v[0]}'>{$v[0]}</option>"; } ?> </select> </div> <br /> <div>信息内容:<textarea name="comment" rows="2"></textarea></div> <br /> <div><input type="submit" value="发送"/> <input type="reset" value="重置"/></div> </form> </td></tr> </table> </div> </body> </html>

      

    发布信息后台处理代码:fabucl.php

    <?php
    session_start();
    if(empty($_SESSION["name"]))
    {
        header("location:login.php");
    }
    
    
    $sender=$_SESSION["name"];
    $recever=$_POST["recever"];
    $comment=$_POST["comment"];
    $times=date("Y-m-d H:i:s");
    
    include("DBDA.class.php");
    $db=new DBDA();
    
    $sql="insert into liuyan values('','{$sender}','{$recever}','{$times}','{$comment}',false)";
    
    $re=$db->Query($sql,1);
    
    if($re)
    {
    	header("location:fabu.php");
    }
    else
    {
    	header("location:fabu.php");
    	echo "<script type='text/javascript'>alert('发送失败!');</script>";
    }
    

      

    4 退出:退出使用状态,清空会话信息,返回登录界面。

    ?php
    session_start();
    if(empty($_SESSION["name"]))
    {
        header("location:login.php");
    }
    
    unset($_SESSION["name"]);
    
    header("location:login.php");
    

      

  • 相关阅读:
    linux的usr目录的全称是什么
    python多线程与多进程及其区别
    redis禁用危险命令
    测试文档
    mysql5.7.23windows安装
    Nginx如何处理手机端和PC端跳转不同页面
    nginx if多条件判断
    centos7单用户模式修改密码
    Django其四
    Django简单搭建编辑页面
  • 原文地址:https://www.cnblogs.com/zst062102/p/5532393.html
Copyright © 2011-2022 走看看