一个很奇怪的问题 单击表格提交,为什么最后面总是出来
代码(很有意思)
<?php
if(isset($_POST[name])){
$name=trim($name);
if(!($myFile=fopen("tt.php","r+")))
{printf("Error: <br>");
printf("Can't open file for read.");
exit;}
$para="/<td class=\"unknow\">$name<\/td>/";
$tobeplace="<td class=\"know\">$name</td>";
static $i=0;
while(!feof($myFile) and $i++<200){
$myline=fgets($myFile,500);
if($myline=preg_replace($para,$tobeplace,$myline)) fputs($myFile,$myline);
}
fclose ($myFile);
header("location:tt.php");
}
?>
<html>
<head>
<title>同学录签到网页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript" type="text/JavaScript">
<!--
function a()
{
o=event.srcElement;
if(o.tagName=="TABLE") return;
while(o && o.tagName!="TD") o=o.parentElement
if (o){
document.all.addname.name.value=o.innerText;
document.all.addname.submit();
}else return;
}
}-->
</script>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="750" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#999999" bgcolor="#FFFFFF" onClick="a()">
<tr>
<td class="unknow">邹云鹏</td>
<td class="unknow">张俊杰</td>
<td class="unknow">梁成禹</td>
<td class="unknow">李自刚</td>
<td class="unknow">王雪峰</td>
</tr>
</table>
<form name="addname" method="post" action="">
<input name="name" type="hidden" id="name">
</form>
</body>
</html>