登陆界面
<body> <form action="dengluchuli.php" method="post"> <h3>登陆界面</h3> <div>开发部内部留言板</div> <div>用户名:<input type="text" name="uid" /></div> <div>口 令:<input type="password" name="pwd" /></div> <input type="submit" value="登陆" /> <input type="reset" value="复位" /> </form> </body>
登陆处理的界面
<body> <form action="dengluchuli.php" method="post"> <h3>登陆界面</h3> <div>开发部内部留言板</div> <div>用户名:<input type="text" name="uid" /></div> <div>口 令:<input type="password" name="pwd" /></div> <input type="submit" value="登陆" /> <input type="reset" value="复位" /> </form> </body>
主页面
<body> <a href="fabuxinxi.php">发布信息</a> <a href="tuichuxitong.php ">退出系统</a> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>发送人</td> <td>发送信息</td> <td>接收人</td> <td>信息内容</td> </tr> <?php session_start(); if(empty($_SESSION["uid"]))//传过来的Uid是否为空 { header("location:denglu.php"); exit;//是的话跳转登陆界面并退出 } $uid = $_SESSION["uid"]; include("../DBDA.class.php"); $db = new DBDA; $sql = "select * from liuyan where recever = '{$uid}' or recever = 'suoyouren'"; $attr = $db->Query($sql); foreach($attr as $v) { $v[1];//处理发送者姓名 $sqlname = "select Name from yuangong where nusername = '{$v[1]}'"; $name = $db->StrQuery($sqlname); //处理接受者姓名 $jieshou = ""; if($v[2]=="suoyouren") { $jieshou = "所有人"; } else { $sqln = "select Name from yuangong where username='{$uid}'"; $jieshou = $db->StrQuery($sqln); } echo" <tr> <td>'{$name}'</td> <td>'{$v[3]}'</td> <td>'{jieshouren}'</td> <td>'{$v[4]}'</td> </tr> "; } ?> </table> </body>
发布信息的页面
<?php session_start(); if(empty($_SESSION["uid"])) { header("location:denglu.php"); exit; } $uid = $_SESSION["uid"]; include("../DBDA.class.php"); $db = new DBDA; ?> <a href="main.php">查看信息</a> <a href="tuchuxitong.php">退出系统</a><br /> <h2>信息发送:</h2> <form action="fasongchuli.php" method="post"> <div>接收人: <select name="jieshou"> <option value="suoyouren">所有人</option> <?php $sql = "select friend from friend where me = '{$uid}'"; $attr = $db->Query($slq); foreach($attr as $v) { $sqln = "select name from yuangong where username = '{$uid}'"; $name = $db->StrQuery($sqln); echo "<option value='{$v[0]}'>{$name}</option>"; } ?> </select> </div> <div>信息内容: <textarea name="neirong"> </textarea> </div> <input type="submit" value="发送" /><input type="reset" value="复位" /> </form> </body>
发送处理
<?php $session_start(); include("../DBDA.class.php"); $db = new DBDA(); $jieshou = $_POST["jieshou"]; $neirong = $_POST["neirong"]; $uid = $_SESSION["uid"]; $time = date("Y-m-d H:i:s"); $SQL = "insert into liuyan values('','{$uid}','{$jieshou}','{$time}','{$neirong}',false)"; if($db->Query($SQL,0)) { header("location:fabu.php"); } else { echo"发布失败!"; }
退出系统
<?php session_start(); unset($_SESSION["uid"]);//清楚session header("location:denglu.php");//清除完后返回登陆界面