Jump to content

Davet

New Members
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Davet

  • Rank
    Newbie
  1. <?php $counter_name = 'counter.txt'; file_put_contents($counter_name, date('Y-m-d H:i:s')."\n", FILE_APPEND); // creates file if it doesn't exist // appends if it does exist $k = 0; $clicks = file($counter_name, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); $clicks = array_reverse($clicks); foreach ($clicks as $dt) { ++$k; echo "$k : $dt<br>"; } ?> <script> $("button.counter").on("click", function(e){ e.preventDefault(); $.ajax({ url: 'counter.php',
  2. Thanks Code: <?php $counter_name = 'counter.txt'; file_put_contents($counter_name, date('Y-m-d H:i:s')."\n", FILE_APPEND); $k = 0; foreach (file($counter_name, FILE_IGNORE_NEW_LINES) as $dt) { ++$k; echo "$k : $dt<br>"; } if (!file_exists($counter_name)) { $f = fopen($counter_name, "w"); fwrite($f,"0"); fclose($f); } $f = fopen($counter_name,"r"); $counterVal = fread($f, filesize($counter_name)); fclose($f); $counterVal++; $f = fopen($counter_name, "w"); fwrite($f, $counterVal); fclose($f); echo $counterVal; ?> Date
  3. <?php $counter_name = 'Counter.txt'; if (!file_exists($counter_name)) { $f = fopen($counter_name, "w"); fwrite($f,"0"); fclose($f); } $f = fopen($counter_name,"r"); $counterVal = fread($f, filesize($counter_name)); fclose($f); $counterVal++; $f = fopen($counter_name, "w"); fwrite($f, $counterVal); fclose($f); echo $counterVal; ?> This is click counter... Counter.txt only number... How to add a date? Counter / Date 1. 2021-02-28 19:50:47 2. 2021-02-23 17:57:11 etc
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.