数据库结构:(库名: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>