<?
include("config.php");

if($admin==$adminpw){
	//接收变量,删除指定的纪录
	$tmp=file($datapath);
	$sum=count($tmp);
	$temp=fopen($datapath,'w');
	for($i=0;$i<$sum;$i++)
   	{
    	//如果是要删除的，不写入文件；其他照写
    	if($i!=$number-1) fwrite($temp,$tmp[$i]);
    	}
	fclose($temp);
	$number=0;
	//header("location:$path");
	}
    elseif(isset($admin)) echo "管理密码输入有误！<br>";

//读取记录并按顺序显示
$record=file($datapath);
$sum=count($record);
for($i=0;$i<$sum;$i++)
   {
    echo $i+1;
    echo " ";
    echo $record[$i];
    echo "<br>";
   }

echo "<form method=\"POST\" action=\"$php_self\">\n";
echo "<p>请输入记录号:<input type=\"text\" name=\"number\" size=\"10\">&nbsp; ";
echo "管理密码:<input type=\"password\" name=\"admin\" size=\"10\" ";
if(isset($admin)) echo"value=$admin";
echo ">　";
echo "<input type=\"submit\" value=\"删除\" name=\"delete\">　";
echo "<input type=\"reset\" value=\"清空\" name=\"reset\"></p>";
echo "</form>";
?>