当前位置:编程学习 > php >>

最简单的留言本(guest.php+post.php+book.txt)

答案:

guest.php
<html>
<head>
<title>最简单的留言本</title>
<body>
<center>最简单的留言本</center>
<hr>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?
$fo = fopen("book.txt","r");
$print = fread($fo,filesize("book.txt"));
fclose($fo);
print "$print";
?></td>
</tr>
</table>
<form method="POST" action="post.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="7%">姓名:</td>
<td width="93%">
<input type="text" name="name" size="20">
</td>
</tr>
<tr>
<td width="7%">内容:</td>
<td width="93%">
<textarea rows="5" name="msg" cols="50"></textarea>

<input type="submit" value="提交" name="B1">
<input type="reset" value="取消" name="B2">
</td>
</tr>
</table>
</form>
</body>
</html>

post.php
<html>
<head>
<title>提交成功!</title>
<meta http-equiv="Refresh" content="1;url=guest.php">
</head>
<body>
<?
if (($name=="") or ($msg=="")){
print "<center>不能提交空内容,填完再提交!
";
}
else{
print "<center>提交成功!
";
$time = date(Y年m月d日H时i分s秒);
$wbook = "<b>$name:</b>
$msg
<b>时间:</b>$time
<hr>";
$fo = fopen("book.txt","a");
fwrite($fo,$wbook);
fclose($fo);
}
?>
</body>
</html>

上一个:多玉米访问一主机实现方法(PHP/ASP/JSP)2005-4-21 01:41:47更新
下一个:php.ini中文版

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,