|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
刚开始写页面程序,调试完书中的例子。然后就可以尝试编写留言板了,网页 当你但愿用本体系创立你的团体主页之前,笔者信任你已设置装备摆设好了相干的阿帕奇办事器,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>
<body background="image/b-graingr1.jpg">
<?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 = "<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>
</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 "<center><b>递交胜利<br>";
?>
<p><br></p>
<p><br></p>
<center><a href="input.php">持续递交</a><a href="guanli.php">办理文件</a></center>
</body>
</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>
在这里想谈谈自己这六个多月的PHP学习心得,希望对给比我还新的新手们有所帮助,讲的不是很深刻,甚至有的想法可能是错误的,希望不要误导新人才好,大家要有自己的主见。 |
|