Home > php教程 > php手册 > 另类留言

另类留言

WBOY
Release: 2016-06-13 10:25:01
Original
970 people have browsed it

对于支持PHP的免费个人主页空间不支持用户的MySQL,怎么编写留言板?其实留言板的编写还有一种很简单的方法,那就是操作文本文件的方式。我在嘻哈免费主页上做了一个,大家可以去留言哦!
写两个PHP文件(note.php和result.php)另外加一个保存留言记录的文本文件(note.txt)。

好了,先看例子:(note.php)

小小留言本


小小留言本




您的大名:


电子邮件:


留言:
Copy after login








$f = fopen("note.txt","r");
$msg = fread($f,filesize("note.txt"));
fclose($f);

print "$msg";
?>

作者:东方一蛇
主页:PHP入门者园地





接着,看result.php





if ($nickname=="") {
print "
您的大名?
";
}
else if ($email=="") {
print "
您电子邮件?
";
}
else if ($note=="") {
print "
您没有要说的吗?
";
}else{
print "
";
$t = date(Y年m月d日);


$note = str_replace ( "$note = str_replace ( ">", ">", $note);
$note = str_replace ( "n", "
", $note);

$main = "网上大名:$nickname:($t)
留言: $note

";
$f = fopen("note.txt","a");
fwrite($f,$main);
fclose($f);
print "
谢谢您的留言!
";


}
?>



返回



作者:东方一蛇
主页:PHP入门者园地



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template