|
1. 用不同的顏我顯示不同人發(fā)表的留言;
2. 每個(gè)留言者具有選擇小圖標(biāo)的功能。
本留言簿要由以下四個(gè)文件組成:記錄留言內(nèi)容的note.txt文件;記錄留言文字顯示顏色的color.txt文件;這兩個(gè)文件都可以有notepad來(lái)創(chuàng)建。反應(yīng)留言表單的note.htm文件;最終處理留言信息的note.php文件。以下是它們的源代碼:
note.htm:
<html>
<head>
<title>===留言簿===</title>
</head>
<body>
<form method="POST" action="note.php">
你的大名:<input type="text" name="name" size="44"><br>
你的郵件地址:<input type="text" name="email" size="40"><br>
你的個(gè)人主頁(yè):<input type="text" name="webname" size="40"><br>
你的個(gè)人主頁(yè)地址:<input type="text" name="webadd" size="35"><br>
你的留言:<br>
<textarea rows="2" name="note" cols="50"></textarea>
請(qǐng)選擇你喜歡的圖標(biāo):
<input type="radio" value="1" checked name="icon"> <img border="0" src="n1.gif" width="19" height="18">
<input type="radio" name="icon" value="2"> <img border="0" src="n2.gif" width="16" height="16">
<input type="radio" name="icon" value="3"> <img border="0" src="n3.gif" width="16" height="16">
<input type="radio" name="icon" value="4"> <img border="0" src="n4.gif" width="19" height="18">
<input type="radio" name="icon" value="5"> <img border="0" src="n5.gif" width="19" height="18">
<input type="radio" name="icon" value="6"> <img border="0" src="n6.gif" width="19" height="18">
<input type="radio" name="icon" value="7"> <img border="0" src="n7.gif" width="15" height="15">
<input type="radio" name="icon" value="8"> <img border="0" src="n8.gif" width="19" height="18">
<input type="radio" name="icon" value="9"> <img border="0" src="n9.gif" width="19" height="18">
<input type="radio" name="icon" value="10"> <img border="0" src="n10.gif" width="18" height="18">
<input type="radio" name="icon" value="11"> <img border="0" src="n11.gif" width="18" height="18">
<input type="radio" name="icon" value="12"> <img border="0" src="n12.gif" width="18" height="18">
<input type="radio" name="icon" value="13"> <img border="0" src="n13.gif" width="15" height="15">
<input type="radio" name="icon" value="14"> <img border="0" src="n14.gif" width="18" height="18">
<input type="radio" name="icon" value="15"> <img border="0" src="n15.gif" width="15" height="15">
</div>
<div align="left">
<input type="submit" value="發(fā)送" name="B1"><input type="reset" value="重寫(xiě)" name="B2">
<a href="note.php?primsg=1">查看留言</a><br>
</div>
</form>
</body>
</html>
其中:nx.gif是小圖標(biāo)圖片,你自己可以更換。
Note.php:
<?
if($primsg==1){
$f = fopen("note.txt","r");
$msg = fread($f,filesize("note.txt"));
fclose($f);
print "$msg"; }
else{
if ($name=="") {
print "你總得給我留下的你的大名吧!否則我如何稱呼你?<br>";}
else if ($note=="") {
print "你總得說(shuō)點(diǎn)什么吧?否則點(diǎn)發(fā)送干什么?不會(huì)是點(diǎn)錯(cuò)了吧?想查看留言??<br>";
}
else{
if ($email=="") {
print "連電子郵件地址也不給留?我如何跟你聯(lián)系?<br>";
}
else if ($webname==""||$webadd="") {
print "你沒(méi)有個(gè)人主頁(yè)?如果有還是希望你給我留下的地址,當(dāng)作是宣傳也可以嘛!<br>";
}
$t = date(Y年m月d日);
$note = str_replace ( "<", "<", $note);
$note = str_replace ( ">", ">", $note);
$note = str_replace ( "/n", "<br>", $note);
$f = fopen("color.txt","r+");
$color1=fread($f,filesize("color.txt"));
if($color1==0){
$color=ff0000;}
else if($color1==1){
$color="0000ff";}
else if($color1==2){
$color="00ff00";
}
else if($color1==3){
$color="000000";
}
if($color1>=3){
$color1=0;}
else{
$color1+=1;
}
fseek($f,0);
fputs($f,$color1);
fclose($f);
for($I=1;$I<=15;$I++){
if($I==$icon){
$pic=$I;
}
}
$str=strval($pic);
$strhtml="<img src='n".$str.".gif'>";
$add="<a href=".$webadd."></a>";
$main = "$strhtml<br><font color=$color><a href=/"mailto:$email/">$name</a>    個(gè)人主頁(yè): $add$webname</a>      ($t)<br>
說(shuō):$note <br>";
$f = fopen("note.txt","a");
fwrite($f,$main);
fclose($f);
$f = fopen("note.txt","r");
$msg = fread($f,filesize("note.txt"));
fclose($f);
echo"$msg";
}
}
?>
php技術(shù):基于文本的留言簿,轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。