【发布时间】:2015-03-24 21:59:30
【问题描述】:
我正在尝试使用表单覆盖存储在 txt 文件中的变量,这是表单代码:
<form action="test.php" method="POST" NAME="action1">
<input type="hidden" name="name" value="<?php echo $amount +10 ?>">
<input type="button" value="increment" onclick="window.document.action1.submit()">
</form>
这里是 test.php 文件:
<?php
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$amount = 0;
fwrite($fh, $amount);
fclose($fh);
?>
我知道我的代码有很多错误,但如果有人告诉我表单代码有什么问题,那就太棒了;感谢您的宝贵时间。
【问题讨论】:
-
你没有在两个 PHP 程序中定义
$amount。
标签: php forms file variables overwrite