当你希望用本系统创建你的个人主页之前,笔者相信你已经配置好了相关的阿帕奇服务器,MYSQL数据库,以及php。
接着启动你的mysql数据库,建立一个名为study的数据库,建立一个名为wenzhang的表。
在phpMyAdmin下建立如下字段:
idsmallint(5)No0auto_increment
timuvarchar(200)Yes
zuozhevarchar(18)Yes
laiyuanvarchar(40)Yes
textttextYes
riqidatetimeYes
单页递交。文件名:input.php
html
head
titleUntitledDocument/title
metahttp-equiv="Content-Type"content="text/html;charset=gb2312"
/head
bodybgcolor="#FFFFFF"background="image/b-graingr1.jpg"
formmethod="post"action="shengcheng.php"
tablewidth="750"border="1"align="center"
tr
tdwidth="53"标题:/td
tdcolspan="3"
inputtype="text"name="timu"size="50"
/td
/tr
tr
tdwidth="53"height="28"作者:/td
tdwidth="154"height="28"
inputtype="text"name="zuozhe"size="20"
/td
tdwidth="59"height="28"来源:/td
tdwidth="456"height="28"
inputtype="text"name="laiyuan"size="30"
/td
/tr
tr
tdwidth="53"正文:/td
tdcolspan="3"
textareaname="textt"cols="90"rows="20"/textarea
/td
/tr
tr
tdwidth="53"/td
tdcolspan="3"
inputtype="submit"name="Submit"value="递交"
inputtype="reset"name="Submit2"value="复位"
/td
/tr
/table
/form
/body
/html
单页生成,文件名:shengcheng.php
html
bodybackground="image/b-graingr1.jpg"
?php
$db=mysql_connect("localhost","root");
mysql_select_db("study",$db);
//把文章写入数据库
$t=date("Y-m-dh:i:s");
$sql="INSERTINTOwenzhang(timu,zuozhe,laiyuan,textt,riqi)
VALUES('$timu','$zuozhe','$laiyuan','$textt','$t')";
$result=mysql_query($sql);
//把计数器加一
$fdd=fopen("count.txt","r");
$cdd=fread($fdd,5);
$cdd++;
fclose($fdd);
$fdd=fopen("count.txt","w");
fwrite($fdd,$cdd);
fclose($fdd);
//文章生成
$muoban1=fopen("muoban1.txt","r");
$muoban2=fopen("muoban2.txt","r");
$muoban3=fopen("muoban3.txt","r");
$qita="ptablewidth="75%"border="0"align="center"
tr
tdclass=p9
divalign="center"作者:fontcolor="#306800"$zuozhe/font??来源:fontcolor="#306800"$laiyuan/font
??时间:fontcolor="#336600"$t/font/div
/td
/tr
/table/p";
$muoban4=fread($muoban1,1000);
$muoban5=fread($muoban2,1000);
$muoban6=fread($muoban3,1000);
fclose($muoban1);
fclose($muoban2);
fclose($muoban3);
$main="$muoban4$timu$qita$muoban5$textt$muoban6";
//文章生成
$ttt=".html";
$n=$cdd.$ttt;
$f=fopen($n,"a");
fwrite($f,$main);
fclose($f);
print"centerb递交成功br";
?
pbr/p
pbr/p
centerahref="input.php"继续递交/a??ahref="guanli.php"管理文件/a/center
/body
/html
#p#分页标题#e#模板提交,文件名:muban.php
html
head
titleUntitledDocument/title
metahttp-equiv="Content-Type"content="text/html;charset=gb2312"
/head
bodybgcolor="#FFFFFF"background="image/b-graingr1.jpg"
formmethod="post"action="muobanshen.php"
tablewidth="750"border="1"
tr
tdwidth="155"标题之前:/td
tdwidth="579"
textareaname="muban1"cols="70"rows="5"/textarea
/td
/tr
tr
tdwidth="155"正文之前:/td
tdwidth="579"
textareaname="muban2"cols="70"rows="5"/textarea
/td
/tr
tr
tdwidth="155"正文之后:/td
tdwidth="579"
textareaname="muban3"cols="70"rows="5"/textarea
/td
/tr
tr
tdcolspan="2"
divalign="center"
inputtype="submit"name="Submit"value="提交"
inputtype="button"name="Submit2"value="复位"
/div
/td
/tr
/table
/form
/body
/html
模板生成,文件名:muobanshen.php
html
head
title测试/title
metahttp-equiv="Content-Type"content="text/html;charset=gb2312"
linkrel="stylesheet"href="image/yifancss.css"
/head
bodyleftmargin="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
centerahref="guanli.php"管理文件/a/center
/p
/body
/html