title: PHP + jQuery/AJAX form submit and loading result
body: <p>I have this form with multiple radio buttons. Exactly 3 inputs per person. I am able to submit and store it to database with ajax and no problems there. My problem is really getting correct info back after submit. In my process.php I'm checking that if the same person has two or more inputs checked it will not insert that data. So that's working correctly too when submitting, only right stuff goes to my db. But when I try get info back from that same file with ajax it always says "Error - 1 per person". I guess the reason is that because I check with $_POST-data and after submit that second time it loads process.php all those $_POST-inputs are equal.</p>
  
  <p>So how could I get that correct info back? Maybe some jQuery? I have no idea at the moment.</p>
  
  <p>Here is some code</p>
  
  <p><strong>JS -part</strong></p>
  
  <pre><code>    $(document).ready(function() { 
      $("[name=insert]").click(function(event) {
          event.preventDefault();
  
      submitForm();   
      ("#content").load("process.php")
       return false; } ); });
  
     // Function to do the AJAX
     function submitForm() {
     $.ajax({type:"POST", url:"process.php", data:$("#myform").serialize(), cache:false, timeout:10000,
           success: function() {
              alert("Succeeded"); 
                        },                           
            error: function () {
                   alert("Error");
                             }
                                      }); }
  </code></pre>
  
  <p><strong>process.php</strong></p>
  
  <pre><code>   $person3=$_POST['person3'];
     $person2=$_POST['person2'];
     $person1=$_POST['person1'];
  
     if(($person3 == $person2) OR ($person3 == $person1) OR ($person2 == $person1)){
  
      echo "&lt;p align='center'&gt;Error - 1 per person&lt;/p&gt;";
  }
  else{
  
    //sql query   
  }   
  </code></pre>