分享
 
 
 

PHP+TEXT留言本(五)

王朝php·作者佚名  2008-12-28
窄屏简体版  字體: |||超大  

現在我們來講一下reply.php的代碼:

---------------------------------

//reply.php

<?

function check_strlen_long($txt)

{

$len=strlen($txt);

$count=0;

for ($i=0;$i<$len;$i++)

{

if (ord($txt[$i])<128)

{ $count=$count+1;}

if (ord($txt[$i])==10 or ord($txt[$i])==32)

{$count=0;}

if ($count>=60)

{

$txt[$i]="n";

$count=0;

}

}

return $txt;

}

function encode ($txt)

{

$txt=strip_tags($txt);

$txt=htmlspecialchars($txt);

$message=StripSlashes($txt);

return $message;

}

$content=file("guest.txt");

$disptext=$content[$record-1];

if ($job=="addreply" and $replyname!="" and $replycontent!="")

{

$content=file("guest.txt");

$count=count($content);

$time = date(Y年m月d日H小時i分);

$ip=$REMOTE_ADDR;

$replycontent=StripSlashes($replycontent);

$replyname=encode($replyname);

$replycontent=htmlspecialchars($replycontent);

$replycontent=check_strlen_long($replycontent);

$replycontent=nl2br($replycontent);

$replycontent=ereg_replace(chr(10),"",$replycontent);

$content[$record-1]=substr($content[$record-1],0,strlen($content[$i])-1); $content[$record-1]=$content[$record-1]."<!--reply><tr><td colspan=4><ul><font color=#AB00E1>回復內容:</font><br>".$replycontent."<br>回復人大名:".$replyname."<br><font color=#CC33FF>時間:$time 來自:$ip</font></ul><hr size=1 color=blue></td></tr>n";

$fp=fopen("guest.txt","w");

for ($i=0;$i<$count;$i++)

{

fputs($fp,$content[$i],strlen($content[$i]));

}

echo "<meta http-equiv=Refresh content=1;url=guest.php>";

exit;

}

?>

<title>zihanonline</title>

<style>

<!--

A:link {text-decoration: none ; color:0000ff}

A:visited {text-decoration: none; color:004080}

A:active {text-decoration: none}

A:hover {text-decoration: underline; color:ff0000}

BODY {FONT-SIZE: 10p}

TH {FONT-SIZE: 10pt}

TD {FONT-SIZE: 10pt}

-->

</style>

<body bgcolor="#FFFFFF" background="back.gif">

<div align=center >

<? include('head.htm');?>

<table border= 1 width= 65% height= 169 cellpadding="8" cellspacing="0" bordercolor="#E3E3E3" >

<form method= POST action=reply.php >

<?

if ($Submit)

{

if ($replyname=="" or $replycontent=="")

{

echo"<tr align=left valign=middle bgcolor=#F0F0F0> ";

echo"<td width= 100% height= 31 > ";

echo "<font color=red>出錯了</font>回復人姓名和回復內容必填-www.devdao.com!";

echo"</td>";

echo"</tr>";

}

}

?>

<? echo $disptext ?>

<tr align="left" valign="middle" bgcolor="#F0F0F0">

<td width= 100% height= 31 bgcolor="#FFFFFF" > 回復大名

<input type= text name= replyname size= 20 >

</td>

</tr>

<tr valign="middle">

<td width= 100% height= 26 align= left bgcolor="#f0f0f0" >

<p>回復內容</p>

</td>

</tr>

<tr align="center">

<td width= 100% height= 52 valign= top bgcolor="#FFFFFF" >

<textarea rows= 6 name= replycontent cols= 46 wrap="VIRTUAL" ></textarea>

</td>

</tr>

<tr valign="middle" align="center" bgcolor="#F0F0F0">

<td width= 100% height= 14 bgcolor="#f0f0f0" >

<input type=hidden name=job value=addreply>

<input type=hidden name=record value=<? echo $record ?>>

<input type= submit value= 提交 name=Submit >

   

<input type=reset value= 重寫 name= B2 >

</td>

</tr>

</form>

</table>

<?include('bottom.htm');?>

</div>

</body>

</html>

------------------

到此為止,php的代碼我們已經寫完,剩下的是您要作一個留言本的本頭和底部 您可以設計任何的樣式.不過記得在本頭上面要有至少3個連接:查看 返回主頁 發郵件.這樣您的留言本系統才算完整.不過由於這是一文本的留言本,所以您不用擔心數據庫的問題,您只要再寫一個guest.txt的文件就完整了.雖然這個留言本沒有mysql等等,可是功能仍然不錯.而且是完全屬於您自己的留言本.好了,下一節我們將為您講述guest.txt的建立和上傳留言本的幾個重要步驟.

未完待續...

 
 
 
免責聲明:本文為網絡用戶發布,其觀點僅代表作者個人觀點,與本站無關,本站僅提供信息存儲服務。文中陳述內容未經本站證實,其真實性、完整性、及時性本站不作任何保證或承諾,請讀者僅作參考,並請自行核實相關內容。
現在我們來講一下reply.php的代碼: --------------------------------- //reply.php <? function check_strlen_long($txt) { $len=strlen($txt); $count=0; for ($i=0;$i<$len;$i++) { if (ord($txt[$i])<128) { $count=$count+1;} if (ord($txt[$i])==10 or ord($txt[$i])==32) {$count=0;} if ($count>=60) { $txt[$i]="n"; $count=0; } } return $txt; } function encode ($txt) { $txt=strip_tags($txt); $txt=htmlspecialchars($txt); $message=StripSlashes($txt); return $message; } $content=file("guest.txt"); $disptext=$content[$record-1]; if ($job=="addreply" and $replyname!="" and $replycontent!="") { $content=file("guest.txt"); $count=count($content); $time = date(Y年m月d日H小時i分); $ip=$REMOTE_ADDR; $replycontent=StripSlashes($replycontent); $replyname=encode($replyname); $replycontent=htmlspecialchars($replycontent); $replycontent=check_strlen_long($replycontent); $replycontent=nl2br($replycontent); $replycontent=ereg_replace(chr(10),"",$replycontent); $content[$record-1]=substr($content[$record-1],0,strlen($content[$i])-1); $content[$record-1]=$content[$record-1]."<!--reply><tr><td colspan=4><ul><font color=#AB00E1>回復內容:</font><br>".$replycontent."<br>回復人大名:".$replyname."<br><font color=#CC33FF>時間:$time 來自:$ip</font></ul><hr size=1 color=blue></td></tr>n"; $fp=fopen("guest.txt","w"); for ($i=0;$i<$count;$i++) { fputs($fp,$content[$i],strlen($content[$i])); } echo "<meta http-equiv=Refresh content=1;url=guest.php>"; exit; } ?> <title>zihanonline</title> <style> <!-- A:link {text-decoration: none ; color:0000ff} A:visited {text-decoration: none; color:004080} A:active {text-decoration: none} A:hover {text-decoration: underline; color:ff0000} BODY {FONT-SIZE: 10p} TH {FONT-SIZE: 10pt} TD {FONT-SIZE: 10pt} --> </style> <body bgcolor="#FFFFFF" background="back.gif"> <div align=center > <? include('head.htm');?> <table border= 1 width= 65% height= 169 cellpadding="8" cellspacing="0" bordercolor="#E3E3E3" > <form method= POST action=reply.php > <? if ($Submit) { if ($replyname=="" or $replycontent=="") { echo"<tr align=left valign=middle bgcolor=#F0F0F0> "; echo"<td width= 100% height= 31 > "; echo "<font color=red>出錯了</font>回復人姓名和回復內容必填-www.devdao.com!"; echo"</td>"; echo"</tr>"; } } ?> <? echo $disptext ?> <tr align="left" valign="middle" bgcolor="#F0F0F0"> <td width= 100% height= 31 bgcolor="#FFFFFF" > 回復大名 <input type= text name= replyname size= 20 > </td> </tr> <tr valign="middle"> <td width= 100% height= 26 align= left bgcolor="#f0f0f0" > <p>回復內容</p> </td> </tr> <tr align="center"> <td width= 100% height= 52 valign= top bgcolor="#FFFFFF" > <textarea rows= 6 name= replycontent cols= 46 wrap="VIRTUAL" ></textarea> </td> </tr> <tr valign="middle" align="center" bgcolor="#F0F0F0"> <td width= 100% height= 14 bgcolor="#f0f0f0" > <input type=hidden name=job value=addreply> <input type=hidden name=record value=<? echo $record ?>> <input type= submit value= 提交 name=Submit > &nbsp;&nbsp;&nbsp; <input type=reset value= 重寫 name= B2 > </td> </tr> </form> </table> <?include('bottom.htm');?> </div> </body> </html> ------------------ 到此為止,php的代碼我們已經寫完,剩下的是您要作一個留言本的本頭和底部 您可以設計任何的樣式.不過記得在本頭上面要有至少3個連接:查看 返回主頁 發郵件.這樣您的留言本系統才算完整.不過由於這是一文本的留言本,所以您不用擔心數據庫的問題,您只要再寫一個guest.txt的文件就完整了.雖然這個留言本沒有mysql等等,可是功能仍然不錯.而且是完全屬於您自己的留言本.好了,下一節我們將為您講述guest.txt的建立和上傳留言本的幾個重要步驟. 未完待續...
美眾議院議長啟動對拜登的彈劾調查
 百态   2023-09-13
上海、濟南、武漢等多地出現不明墜落物
 探索   2023-09-06
印度或要將國名改為「巴拉特」
 百态   2023-09-06
男子為女友送行,買票不登機被捕
 百态   2023-08-20
手機地震預警功能怎麽開?
 干货   2023-08-06
女子4年賣2套房花700多萬做美容:不但沒變美臉,面部還出現變形
 百态   2023-08-04
住戶一樓被水淹 還衝來8頭豬
 百态   2023-07-31
女子體內爬出大量瓜子狀活蟲
 百态   2023-07-25
地球連續35年收到神秘規律性信號,網友:不要回答!
 探索   2023-07-21
全球鎵價格本周大漲27%
 探索   2023-07-09
錢都流向了那些不缺錢的人,苦都留給了能吃苦的人
 探索   2023-07-02
倩女手遊刀客魅者強控制(強混亂強眩暈強睡眠)和對應控制抗性的關系
 百态   2020-08-20
美國5月9日最新疫情:美國確診人數突破131萬
 百态   2020-05-09
荷蘭政府宣布將集體辭職
 干货   2020-04-30
倩女幽魂手遊師徒任務情義春秋猜成語答案逍遙觀:鵬程萬裏
 干货   2019-11-12
倩女幽魂手遊師徒任務情義春秋猜成語答案神機營:射石飲羽
 干货   2019-11-12
倩女幽魂手遊師徒任務情義春秋猜成語答案昆侖山:拔刀相助
 干货   2019-11-12
倩女幽魂手遊師徒任務情義春秋猜成語答案天工閣:鬼斧神工
 干货   2019-11-12
倩女幽魂手遊師徒任務情義春秋猜成語答案絲路古道:單槍匹馬
 干货   2019-11-12
倩女幽魂手遊師徒任務情義春秋猜成語答案鎮郊荒野:與虎謀皮
 干货   2019-11-12
倩女幽魂手遊師徒任務情義春秋猜成語答案鎮郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手遊師徒任務情義春秋猜成語答案鎮郊荒野:指鹿為馬
 干货   2019-11-12
倩女幽魂手遊師徒任務情義春秋猜成語答案金陵:小鳥依人
 干货   2019-11-12
倩女幽魂手遊師徒任務情義春秋猜成語答案金陵:千金買鄰
 干货   2019-11-12
倩女幽魂手遊師徒任務情義春秋猜成語答案金陵:倒履相迎
 干货   2019-11-12
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有