title: Insert mySQL query if checkbox checked/not checked with PHP
body: <p>During the process of trying to develop an checkbox activated mySQL query based on the value inside a checkbox i've incurred an problem which i can't get past, I've tried the following at the moment</p>
  
  <pre><code>&lt;input type="checkbox" name="status" onclick="updateStatus(&lt;? echo $data['id']; ?&gt;,this.checked)"&gt;
  </code></pre>
  
  <p>The Javascript/Ajax code for the function "updateStatus" is as followed</p>
  
  <pre><code>function updateStatus(id,value) {
  if (window.XMLHttpRequest) {
      http = new XMLHttpRequest()
  } else if (window.ActiveXObject) {
      http = new ActiveXObject("Microsoft.XMLHTTP")
  } else {
      alert("Your browser does not support XMLHTTP!")
  }
  http.abort();
  http.open("GET", "../functions/ajax.php?check=update_status&amp;id=" + id + "&amp;checked="+value, true);
  http.onreadystatechange = function () {
       if (http.readyState == 4) {
          alert(http.responseText);
       }
   }
   http.send(null)
  </code></pre>
  
  <p>The PHP function inside functions/ajax.php</p>
  
  <pre><code>if(isset($check) and $check == 'update_status' and isset($_GET['id'])){
      $id = mysql_real_escape_string($_GET['id']);
      $checked= mysql_real_escape_string($_GET['checked']);
  if($checked == true) {
      echo "Checked";
  } elseif($checked == false) {
      echo "Not checked";
  } else {
      echo "Invalid response";
  }
  </code></pre>
  
  <p>when using this code it always returned "Checked" any idea why ?</p>