Right, ive got this script. Its recording how many times a button is pressed. Its been bugging me for hours why it wont work but its just figured it out, but the reason it wont work cannot be easily solved!
Ill keep it as simple as possible. I have something like this:
Code:
<?php
$logFile = 'countLog.log';
$totalCount = (int)file_get_contents($logFile);
if($_POST['button1']){
$fp = fopen($logFile, 'w');
$totalCount = $totalCount + 1;
fwrite($fp, $totalCount);
fclose($fp);
}
?>
<form method="post">
<input type="submit" name="button1">
</form>
<br/><br/>
Form has been submitted <?php echo $totalCount; ?> times.
(
EXAMPLE)
That works. However I have my own form, which is fine, but there is ONE tiny, ESSENTIAL bit that stops it from working..
action="contact.php"
If I simply rmove that bit it counts fine. But as you can guess, i NEED that line, or the form is useless for anything
other than counting how many times its been clicked! Thats clearly no good.
Any ideas how I can fix this??
So basicaly, if I keep the bit
action="contact.php" then the form submits ok but it wont count, but if I remove that line then it will count ok but it wont submit anything anywhere!
Its a bit hard to explain so im not sure if ive made myself clear. But, please help if you can!!
Thank youuu
Lloyd