Skip to content

Instantly share code, notes, and snippets.

@LinuxPhreak
Created August 21, 2013 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LinuxPhreak/6291757 to your computer and use it in GitHub Desktop.
Save LinuxPhreak/6291757 to your computer and use it in GitHub Desktop.
<?php
$f = fopen('counter.txt', 'r+');
flock($f, LOCK_EX);
$total = (int) fread($f, max(1, filesize('counter.txt')));
if (isset($_POST['submit'])) {
rewind($f);
fwrite($f, ++$total);
}
fclose($f);
?>
<form action='' method="post">
<input type="submit" name="submit" value="click" />
</form>
This button has been clicked <?php echo $total; if($total >= 100){echo 'More then 100';} ?> times.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment