另類留言_PHP教程

來源:互聯網
上載者:User
對於支援PHP的免費個人首頁空間不支援使用者的MySQL,怎麼編寫留言板?其實留言板的編寫還有一種很簡單的方法,那就是操作文字檔的方式。我在嘻哈免費首頁上做了一個,大家可以去留言哦!
寫兩個PHP檔案(note.php和result.php)另外加一個儲存留言記錄的文字檔(note.txt)。

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

小小留言本


小小留言本



您的大名:


電子郵件:


留言:







$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);
$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入門者園地


http://www.bkjia.com/PHPjc/532097.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/532097.htmlTechArticle對於支援PHP的免費個人首頁空間不支援使用者的MySQL,怎麼編寫留言板?其實留言板的編寫還有一種很簡單的方法,那就是操作文字檔的方...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.