码迷,mamicode.com
首页 > Web开发 > 详细

php入门实现留言板

时间:2015-08-12 23:00:35      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

首先由一个文本文档read.txt

liulan.html

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>留言</title>
</head>
<body>
    <form action="./1.php" method="post">
        <p>标题:<input type="text" name="title"></p>
        <p>留言:<textarea name="neirong" cols="50" rows="5"></textarea></p>
        <p><input type="submit" value="提交"></p>
    </form>
</body>
</html>

 1.php

<?php
$arr=$_POST[‘title‘].",".$_POST[‘neirong‘]."\n";
$fo=fopen("./read.txt","a");
fwrite($fo, $arr);
fclose($fo);
echo "ok","\n";
echo "<a href=‘2.php‘>","查看资源","</a>";

?>

 2.php

<?php
$fo=fopen("./read.txt",‘r‘);
$i=1;
while(($row=fgetcsv($fo))!=false){
    echo "<a href=‘3.php?tid=",$i,"‘>",$row[0],"</a>","\n";
    $i=$i+1;
}
fclose($fo);
?>

 3.php

<?php
$tid=$_GET["tid"];
$fo=fopen("./read.txt","r");
$i=1;
while(($row=fgetcsv($fo))!=false){
    if($tid==$i){
        print_r($row);
    }
}
fclose($fo)
?>

 

php入门实现留言板

标签:

原文地址:http://www.cnblogs.com/lzzhuany/p/4725665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!