首先由一个文本文档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) ?>
时间: 2024-10-29 10:46:36