#一个最最简单的留言程序

#一个最最简单的留言程序
#使用时只要把以下代码存为 php文件就行了
<?
$fileName="data.txt";
if($action == "send")
{
$message = ereg_replace("/r/n", "<br>", $message);#把PHP换行符转换为HTML格式br
$message = ereg_replace(" ", "&nbsp;&nbsp;", $message);#空格转换
$Today = date("F dS, Y");#日期
$data = $name."/r/n".$Today."/r/n".$message."/r/n";
$fileContent = fopen("$fileName", "a");#留言数目
if(Chop($name)!="" && Chop($message)!="")
#删除字符串结尾的空白字符
{
fwrite($fileContent, "$data");
fclose($fileContent);
}
$action = "";#若不设置为空 会使页面混乱
}
?>

<html>
<head>
<title>冷风-哈哈改成自己的吧 </title>
</head>
<table border="1" width="100%" bordercolorlight="#C0C0C0" #本表格用于显最上面的标题
cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF"
bgcolor="#E4E4E4" >
<tr>

<td width="16%" align="center" style="font-size:10.5pt">
冷风-哈哈改成自己的吧 &nbsp&nbsp&nbsp&nbsp讨论版块</a>
</td>
</tr>
</table><br><br>

<body >
<?
if(file_exists($fileName))
{
$fileMessage=file($fileName);
#将文件$fileName中所有内容读入数组$fileMessage
#一行内容保存在一个数组元素中
}

?>

<table width="100%" border="0" bgcolor="#E4E4E4">#以下是重点,将PHP格式专为html
<?

for($i=0; $fileMessage[$i]!="";)
{
print(" <tr>/r/n");
print(" <td>");
print(" 发信人: <font color=/"#000000/">".$fileMessage[$i++]."</font></td>/r/n");
print(" <td><div align=/"right/"><font color=/"#000000/">".$fileMessage[$i++]."</font></div></td>");
print(" </tr>/r/n<tr>/r/n");
print(" <td colspan=/"2/"bgcolor=/"#FFFFFF/">");
print(" <br><font color=/"#000000/">".$fileMessage[$i++]."</font></td>/r/n");
print(" </tr>/r/n");
}
?>
</table>#以下是用户提较的表单

<form action="discuss.php" method="POST" target="_self">
<input type="hidden" name="action" value="send">
<table border="1" width="100%" bordercolorlight="#C0C0C0"
cellspacing="0" bordercolordark="#FFFFFF" bgcolor="#E4E4E4" >
<tr>
<td width="10%" align="left">你的姓名:</td>
<td width="10%">
<input type="text" name="name" size="90">&nbsp;
<font color="#8080C0"></font>
</td>
</tr>

<tr>
<td width="10%" align="left" >发言内容:</td>
<td width="10%" >
<textarea rows="8" name="message" cols="90" maxlength="1000">
</textarea>
<font color="#8080C0"></font>
</td>
</tr>


</table>
<p align="center">
<INPUT type="submit" value="给我发" name="OK"style="color: #404040; font-size: 12px; border-style: solid; border-color: #cccccc">
&nbsp; <FONT style="font-size:9pt">
<INPUT type="button" value="给我闪" name="reset"style="color: #404040; font-size: 12px; border-style: solid; border-color: #cccccc">

</p>
</form>

<P align="center"></a> </p>

<HR width="90%" color="#000000" size="5">
<DIV align="center">

<P align="center">
<FONT color="#000000" size="2">
留言程序:冷风袭人
</FONT>
<P>
</DIV>
<HR width="90%" color="#000000" size="5">
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值