數據庫結構:(庫名:lyb)
表一: admin
字段: id(int11) name(varchvr) password(varchvr)
表二: lo
字段: id(int11) username(varchvr) sex(varchvr) qq(varchvr) email(varchvr) info(text) ip(varchvr) submit_time(datetime)
1、conn.php(連接數據庫文件)
<?php
mysql_connect("localhost","root","");//連接數據庫
mysql_select_db("lyb");//選擇數據庫
?>
2、header.php(公用頭部文件)
<!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=gb2312" />
<title>銀子留言板 Version 1.0</title>
</head>
<link href="css.css" rel="stylesheet" type="text/css" />
<body>
<div id="head">
<div id="head_l">
<ul>
<li><a href="index.php">偶要看留言</a></li>
<li><a href="post.php">偶要發表</a></li>
<?php
session_start();
if($_SESSION["key"]==1){//如果獲取的SESSION為1則顯示管理項
?>
<li><a href="adminexit.php">退出管理</a></li>
<?
}
else
{
?>
<li><a href="admin.php">偶要管理</a></li>
<?}?>
</ul>
</div>
<div id="head_r">銀子留言板 Version 1.0</div>
</div>
3、footer.php(公用底部文件)
<?php
$counterFile="conter.xml";
function displayCounter($counterFile){
$fp = fopen($counterFile,"rw");
$num = fgets($fp,5);
$num += 1;
print "<div id=\"footer\">銀子留言板 Version 1.0 您是第 "."$num"." 位無聊的銀</div>";
exec("rm -rf $counterFile");
exec("echo $num > $counterFile");
}
if(!file_exists($counterFile)){
exec("echo 0 > $counterFile");
}
displayCounter($counterFile);
?>
</body>
</html>