title: ajax post method and php
body: <p>Ho all, here I explain my problem (as far as i red i didnt find any working solution).
  here I link my files:</p>
  
  <p>progetto.html</p>
  
  <pre><code>&lt;html&gt; 
  &lt;head&gt; 
      &lt;script type="text/javascript" src="funzioni.js"&gt;&lt;/script&gt;
      &lt;title&gt;Pagina iniziale&lt;/title&gt;
  &lt;/head&gt;
  &lt;body align='center'&gt;
      &lt;p&gt;Gymnasium&lt;/p&gt;
      &lt;p&gt;icona&lt;/p&gt;
      &lt;form id="ajaxForm" name="ajaxForm"&gt;
          &lt;table align="center"&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;label&gt;Utente&lt;/label&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="user" id="user" value="" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;label&gt;Password&lt;/label&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="password" name="password" id="password" value="" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;input type="button" id="submit" name="submit" value="Accedi" onclick='submitForm()' /&gt;
      &lt;/form&gt;
      &lt;div id="risultato"&gt;&lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>javascript file</p>
  
  <pre><code>function createXMLHttpRequestObject(){
  if (window.XMLHttpRequest) { return new XMLHttpRequest(); }
  if (window.ActiveXObject) { return new ActiveXObject(Microsoft.XMLHTTP); }
  return null;
  </code></pre>
  
  <p>}</p>
  
  <pre><code>function submitForm(){
  var ajax = createXMLHttpRequestObject();
  ajax.onreadystatechange = function () {
                          if (ajax.readyState==4 &amp;&amp; ajax.status==200){
                          var response = ajax.responseText;
                          document.getElementById("risultato").innerHTML = response;
                      }
                  }
  ajax.open("post", "ajaxLogin.php", true);
  var data = "utente=" + document.getElementById('user').value + "&amp;password=" + document.getElementById('password').value; 
  ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ajax.send(data);
  </code></pre>
  
  <p>}</p>
  
  <p>ajaxLogin.php</p>
  
  <pre><code>&lt;?php
  if (!isset($_POST["user"]) || !isset($_POST["password"])){
      die("Bad login");
  }
  $user = $_POST['user'];
  $pwd = $_POST['password'];
  if ( (($user == "angel") &amp;&amp; ($pwd == "devil")) || (($user == "john") &amp;&amp; ($pwd == "smith")) ){
      $response = "Benvenuto  " . $user;
      echo $response;
  }
  </code></pre>
  
  <p>?></p>
  
  <p>Problem is I always receive Bad Login message even if I use the right user and password.
  It's a POST problem with I'm really having hard time figuring out the solution.  </p>