1
我有一个脚本,当某个按钮被按下时,它将+1或-1加到变量上。 “+1”按钮可以很好地工作,但当变量的值为“10”时(也可能是其他值),“-1”按钮会变为奇数。当我点击按钮时,不显示“9”,而是显示“90”。计算按钮点击次数的PHP脚本
PHP:
<?php
$myfile = fopen("response.txt", "r+") or die("Unable to open file!");
$currentvalue = file_get_contents("response.txt");
$currentvalue = $currentvalue -1;
fwrite($myfile, $currentvalue);
fclose($myfile);
header('Location: otherfile.php') ;
?>
HTML
<form method="post" action="minus.php">
<button> Remove one </button>
</form>
我知道有这项任务更好的方法,但上面的代码是我能想出,考虑到我的基本知识最好PHP。
谢谢。
感谢您的快速响应,它的工作原理。 – C10H15N