title: How to post JQuery variable into database
body: <p>I try javascript typing game by nikola. Here is the link  <a href="https://codepen.io/nikola1970/pen/oxXbmb" rel="nofollow noreferrer">codepen.io/nikola1970/pen/oxXbmb</a> and When the time's up i want to post the points i get to the score table on my database. </p>
  
  <pre><code>CREATE TABLE public.score
  (
    id bigserial,
    score integer,
    user character varying(50),
    "timestamp" timestamp without time zone,
  )
  </code></pre>
  
  <p>how can i do?</p>
  
  <p>I add the countdown function like this.</p>
  
  <pre><code>function countdown() {
      points = 0;
      var timer = setInterval(function(){
          button.disabled = true;
          seconds--;
          temp.innerHTML = seconds;
          if (seconds === 0) {
  
                  if (window.XMLHttpRequest) {
                      xmlhttp = new XMLHttpRequest();
                  }
  
                  xmlhttp.open("GET", "ajax.php?points=" + points , true);
                  xmlhttp.send();
  
                 // return false;
  
              alert("Game over! Your score is " + points);
               //Done!
              scoreDiv.innerHTML = "0";
              words.innerHTML = "";
              button.disabled = false;
              clearInterval(timer);
              seconds = 60;
              timerDiv.innerHTML = "60";
              button.disabled = false;    
          }
      }, 10);
  }
  </code></pre>
  
  <p>and here is my ajax.php</p>
  
  <pre><code>&lt;?php
  session_start();
  
   include("config.php");
  
  
  $score = $_GET['points'];
  $user = $_SESSION['id'];
  
  
  $query = pg_query(" insert into t_score (score, id_user, timestamp) values ('$score', $user, 'now()') ") ;
  pg_close()
  ?&gt;
  </code></pre>
  
  <p>i've editted my countdown function and ajax.php. now it's work to send the score to the database.</p>