當你希望用本系統建立你的個人首頁之前,筆者相信你已經配置好了相關的阿帕奇伺服器,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
Untitled Document
單頁產生,檔案名稱:shengcheng.php
$db = mysql_connect("localhost", "root");
mysql_select_db("study",$db);
// 把文章寫入資料庫
$t = date("Y-m-d h:i:s");
$sql = "INSERT INTO wenzhang (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 = "
作者:$zuozhe 來源:$laiyuan
時間:$t
";
$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 "
遞交成功
";
?>
繼續遞交管理檔案
(待續)http://www.bkjia.com/PHPjc/531991.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/531991.htmlTechArticle當你希望用本系統建立你的個人首頁之前,筆者相信你已經配置好了相關的阿帕奇伺服器,MYSQL資料庫,以及php。 接著啟動你的mysql資料庫...