以下代码是 HTML 和 php 代码。我想要如果按下提交按钮而不是执行 practice.php 文件(制作 test.txt 文件)。但是如果我按下按钮 php 不会生成文件。有谁知道这个??
<HTML>
<HEAD>
</HEAD>
<BODY onLoad="tid=setInterval('refresh()',1000);">
<div id="outputDiv"></div>
<form method=post action="practice.php">
<script language="JavaScript">
function refresh()
{
var HTML = "";
HTML += "<input type=submit value=makefile>";
document.getElementById("outputDiv").innerHTML = HTML;
}
</script>
</form>
</BODY>
</HTML>
<html>
<head><meta http-equiv="Content-Type" content="text/html" charset="utf-8">
</head>
<body>
<?
$fp = fopen("test.txt", "w") or die("cannot open file");
$data = "!!!!!!!!!!!!!!!!!!!";
fwrite($fp, $data);
fclose($fp);
echo "!!!!!!!!!!!!!!!";
?>
</body>
</html>