title: Retrieving POST Data from AJAX Call to PHP
body: <p>Three days had passed and still having problems to get this things work. 
  This AJAX Call on my js file seems working when it comes to sending JSON data:</p>
  
  <pre><code> var _lname = $('#ptLastName').val();
   var _fname = $('#ptFirstName').val();
   var _mname = $('#ptMiddleName').val();
   var _gender = $('#ptGender').val();
   var _bday = $('input[name="birthdate"]').val(); // $('#ptBirthDate').val();
   var _ssn = $('#ptSSN').val();
  
   $.ajax({
            type: "POST",
            url: ".././CheckPerson.php",
            data: "{'lastName':'" + _lname + "','firstName':'" + _fname + "','middleName':'" + _mname + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response) {
            var res = response.d;
            if (res == true) {
                 jAlert('Person Name already exists!', 'Error');
                 return;
            } 
  })
  </code></pre>
  
  <p>but in my PHP file:</p>
  
  <pre><code>$lastname = json_decode($_POST['lastName']);
  $firstname = json_decode($_POST['firstName']);
  $middlename = json_decode($_POST['middleName']);
  $response = array();
  
  mysql_connect ("*****", "****") or die ('Error: ' . mysql_error());
  mysql_select_db ("********");
  
  $query = "SELECT Lastname, Firstname, MiddleName FROM tbl_people WHERE Lastname = '$lastname' || Firstname = '$firstname' || MiddleName = '$middlename'";
  
  $result = mysql_query($query);
  
  $row = mysql_fetch_array($result);
  
      if ($row) {     
          $response = json_encode(array('d' =&gt; true, 'test' =&gt; $lastname)); 
      }
      else { 
      $response = json_encode(array('d' =&gt; false, 'test' =&gt; $lastname));
      }
  echo $response;
  print json_encode($_POST);
  </code></pre>
  
  <p>some error from firebug console says:</p>
  
  <pre><code>&lt;br /&gt;
  &lt;b&gt;Notice&lt;/b&gt;:  Undefined index: lastName in &lt;b&gt;C:\xampp\htdocs\..\CheckPerson.php&lt;/b&gt; on line &lt;b&gt;2&lt;/b&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;b&gt;Notice&lt;/b&gt;:  Undefined index: firstName in &lt;b&gt;C:\xampp\htdocs\..\CheckPerson.php&lt;/b&gt; on line &lt;b&gt;3&lt;/b&gt;&lt;br /&gt;
  &lt;br /&gt;
  &lt;b&gt;Notice&lt;/b&gt;:  Undefined index: middleName in &lt;b&gt;C:\xampp\htdocs\..\CheckPerson.php&lt;/b&gt; on line &lt;b&gt;4&lt;/b&gt;&lt;br /&gt;
  {"d":false,"test":null}[]
  </code></pre>
  
  <p>i believe that <code>json_decode()</code> is working fine in my php file but <code>$_POST['']</code> can't recognize my posted data from my ajax call w/c variables had been declared:</p>
  
  <pre><code>data: "{'lastName':'" + _lname + "','firstName':'" + _fname + "','middleName':'" + _mname + "'}",
  </code></pre>
  
  <p>I believe I am doing right with my codes seems i had read many questions here and done what they had said but don't know why the error occurred.
  Is there any problem/bug you had seen? please tell me.</p>