SHARE
TWEET

Untitled

a guest Dec 2nd, 2012 38 Never
  1. -- HTML
  2. Your score is <span>0</span>
  3. <button>Click me</button>
  4.  
  5. -- Javascript include jquery
  6. $('button').click(function() {
  7.    $.get('file.php', function(data) {
  8.      $('span').html(data);
  9.    }
  10. })
  11.  
  12. -- PHP
  13. <?php
  14. session_start();
  15. if (!isset($_SESSION['scorekeeper']) {
  16.   $_SESSION['scorekeeper'] = 1; // 1 because this is the first button press
  17. } else {
  18.   $_SESSION['scorekeeper']++;
  19. }
  20.  
  21. echo $_SESSION['scorekeeper']
RAW Paste Data
Top