本軟件是作為部門內員工之間留言及發送消息使用。
系統必須通過口令驗證,登錄進入。方法是從數據庫內取出用戶姓名和口令的數據進行校驗。
?
系統包含四部分功能
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();//啟動sessioninclude("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]; //服務器記錄sessionheader("location:liuyan.php");
}
else
{header("location:login.php");
}
?
2 信息查詢:顯示給當前登錄人留的信息以及公共信息(給所有人發送)。
?
留言信息界面顯示代碼
<title>留言信息</title>
<style type="text/css">
#two
{width: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><?phpinclude("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
{width: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><?phpinclude("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");
?