title: Inserting data using ajax issue
body: <p>I am trying to insert data on my database using ajax, nothing is working.  Can any tell me what I am doing wrong please?</p>
  
  <p>INDEX.PHP</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Title&lt;/title&gt;
          &lt;script type="text/javascript"&gt;
              function myLoad(){
                  if(window.XMLHttpRequest){
                      var xmlhttp = new XMLHttpRequest();
                  }else{
                      var xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
                  }
  
                  xmlhttp.open('GET', 'generate.php?text=' + document.getElementById('textarea').value, true);
                  xmlhttp.send();
                  xmlhttp.onreadystatechange = function(){
                      if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200){
                          window.document.getElementById('par').innerHTML = xmlhttp.responseText;
                      }
                  }
              }
          &lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;div id="par"&gt;&lt;/div&gt;
          &lt;input type="text" id="textarea"&gt;
          &lt;input type="button" id="button" value="Click Me" onClick="myLoad();"/&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>GENERATE.PHP</p>
  
  <pre><code>&lt;?php
      require 'php/connect.inc.php';
  
      if(isset($_GET['text']) &amp;&amp; !empty($_GET['text'])){
          $name = $_GET['text'];
          $query = "INSERT INTO users VALUES('', '$name', 'pass123', 'greg')";
  
          if($mysql_query = mysql_query($query)){
              echo 'Success';
          }else{
              echo 'Failed';
          }
      }
  ?&gt;
  </code></pre>
  
  <p>CONNECT.INC.PHP</p>
  
  <pre><code>&lt;?php
      $mysql_host = 'localhost';
      $mysql_user = 'root';
      $mysql_pass = '';
  
      $mysql_error = 'Could not connect';
      $a_database = 'a_database';
  
      if(!@mysql_connect($mysql_host, $mysql_user, $mysql_pass) OR !@mysql_select_db($a_database)){
          die($mysql_error);
      }
  ?&gt;
  </code></pre>