maysen
新手上路

UID 93878
精华
0
积分 12
帖子 9
金钱 12 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2007-6-13
状态 离线
|
[广告]: 代充Paypal帐号美元
小第看留言本教程有点不明白,达人请进。
小弟刚开始学习php看了个留言本教程看明白了。想先把他的范例程序看下效果,结果报错
Notice: Undefined variable: action in D:\www\test\lyben.php on line 3
麻烦高人们给小弟说下错在那里吧。谢谢啦。在线等
代码如下:
<?php
$fileNme = "data.txt";
if($action=="send") //说的是这行错误。
{
$message = ereg_replace("r\\n","<br>",$message);
$message = ereg_replace(" ","  ",$message);
$Today = date("Y/m/d H:i:s");
$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>maysen</title>
</head>
<body bgcolor=#ffffff text="#333333">
<?
if(file_exists($fileName))
{
$fileMessage=file($fileName);
}
$count=count($fileMessage)/3;
?>
<table width="99%"border="0"bgcolor="#ffefb0">
<?
print(" <tr><td colspan=\"2\"bgcolor=\"#fffae6">"留言数:".$count."</td></tr>\r\n");
for($i=0;$fileMessage[$i]!="";)
{
print(" <br>\r\n");
print(" <td>");
print(" Name:<font color=\"#ff0000\">".$fileMessage[$i++]."</font></td>\r\n");
print(" <td><div align=\"right\"><font color=\"#777777\">".$fileMessage[$i++]."</font></div></td>");
print(" </tr>\r\n<tr>\r\n");
print(" <td colspan=\"2\" bgcolor=\"#fffae6\">");
print(" Message:<br><font color=\"#0000cc\">".$fileMessage[$i++]."</font></td>\r\n");
print(" </tr>\r\n");
}
?></table>
<form action = "lyben.php" method = "POST" target = "_self">
<input type ="hidden"name="action" value="send">
姓名:<br>
<input name="name" size=30 maxlength=15><br>
<textarea name="message" rows="12"cols="51"></textarea><br>
<input type="submit"value="发出留言"><br>
</form>
</body>
</html>
[ 本帖最后由 maysen 于 2007-6-14 05:58 PM 编辑 ]
|
|