當你希望用本系統創建你的個人主頁之前,筆者相信你已經配置好了相關的阿帕奇服務器,MYSQL數據庫,以及php。
接著啟動你的mysql數據庫,建立一個名為study的數據庫,建立一個名為wenzhang的表。
在phpMyAdmin下建立如下字段:
id smallint(5) No 0 auto_increment
timu varchar(200) Yes
zuozhe varchar(18) Yes
laiyuan varchar(40) Yes
textt text Yes
riqi datetime Yes
單頁遞交。文件名:input.php
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" background="image/b-graingr1.jpg">
<form method="post" action="shengcheng.php">
<table width="750" border="1" align="center">
<tr>
<td width="53">標題:</td>
<td colspan="3">
<input type="text" name="timu" size="50">
</td>
</tr>
<tr>
<td width="53" height="28">作者:</td>
<td width="154" height="28">
<input type="text" name="zuozhe" size="20">
</td>
<td width="59" height="28">來源:</td>
<td width="456" height="28">
<input type="text" name="laiyuan" size="30">
</td>
</tr>
<tr>
<td width="53">正文:</td>
<td colspan="3">
<textarea name="textt" cols="90" rows="20"></textarea>
</td>
</tr>
<tr>
<td width="53"> </td>
<td colspan="3">
<input type="submit" name="Submit" value="遞 交">
<input type="reset" name="Submit2" value="復 位">
</td>
</tr>
</table>
</form>
</body>
</html>
單頁生成,文件名:shengcheng.php
<html>
模板提交,文件名:muban.php
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" background="image/b-graingr1.jpg">
<form method="post" action="muobanshen.php">
<table width="750" border="1">
<tr>
<td width="155">標題之前:</td>
<td width="579">
<textarea name="muban1" cols="70" rows="5"></textarea>
</td>
</tr>
<tr>
<td width="155">正文之前:</td>
<td width="579">
<textarea name="muban2" cols="70" rows="5"></textarea>
</td>
</tr>
<tr>
<td width="155">正文之後:</td>
<td width="579">
<textarea name="muban3" cols="70" rows="5"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="Submit" value="提 交">
<input type="button" name="Submit2" value="復 位">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
模板生成,文件名:muobanshen.php
<html>
<head>
<title>測試</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="image/yifancss.css">
</head>
<body leftmargin="0" topmargin="0" link="#000066" vlink="#000068" alink="#000068" background="image/b-graingr1.jpg">
<p>
<?
$fdd=fopen("muoban1.txt","w");
fwrite($fdd,$muban1);
fclose($fdd);
$fdd=fopen("muoban2.txt","w");
fwrite($fdd,$muban2);
fclose($fdd);
$fdd=fopen("muoban3.txt","w");
fwrite($fdd,$muban3);
fclose($fdd);
echo "模板修改成功!<p>";
?>
<br>
<center><a href="guanli.php">治理文件</a></center>
</p>
</body>
</html>
網站治理,文件名:guanli.php
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" background="image/b-graingr2.jpg">
<table width="775" border="0">
<tr>
<td width="101" height="463" valign="top">
<p><img src="image/piao.gif" width="103" height="60"></p>
<p><img src="image/a.gif" width="100" height="35"></p>
<p><a href="muban.php"><img src="image/b.gif" width="100" height="35" border="0"></a></p>
<p><img src="image/c.gif" width="100" height="35"></p>
<p><img src="image/d.gif" width="100" height="35"></p>
<p><img src="image/e.gif" width="100" height="35"></p>
<p><img src="image/f.gif" width="100" height="35"></p>
</td>
<td width="663" height="463" valign="top">
<table width="95%" border="0" align="center" height="234">
<tr>
<td height="43">
<div align="center"><b><font color="#480000" size="6">頁面治理</font></b></div>
</td>
</tr>
<tr valign="top">
<td height="267">
<?php
// 程序開始
$db = mysql_connect("localhost", "root");
mysql_select_db("study",$db);
// 判定是不是修改文件
if ($submit) {
$sql = "UPDATE wenzhang SET timu='$timu',zuozhe='$zuozhe',
laiyuan='$laiyuan',textt='$textt' WHERE id=$id";
// 向數據庫發出SQL命令
$result = mysql_query($sql);
// 文章生成
$t = date("Y-m-d h:i:s");
$muoban1 = fopen("muoban1.txt","r");
$muoban2 = fopen("muoban2.txt","r");
$muoban3 = fopen("muoban3.txt","r");
$qita = "<p><table width="75%" border="0" align="center">
<tr>
<td class=p9>
<div align="center">作者:<font color="#306800">$zuozhe</font> ??來源:<font color="#306800">$laiyuan</font>
??時間:<font color="#336600">$t</font> </div>
</td>