留言本之发布留言留言本之发布留言


先创建一个index.text

<?php 

	$str=$_POST['name'].",".$_POST['email'];
	$fh=fopen('index.txt','a'); //打开文件
	fwrite($fh, $str); //写入数据
	fclose($fh); //关闭文件
	echo "ok";


 ?>

然后在Index.html中随意输入数据,再打开index.text查看是否写入数据

##留言本之读取数据 ##

<?php 

	
	$fh=fopen('index.txt','r'); //打开文件
	while (fgetcsv($fh)!=false) {  //直到无法读取数据
		# code...
		echo "$fh";
	}

 ?>