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