title: PHP PDO loop different in JS and PHP
body: <p>I'm trying to make a loop to add all POST keys to PDO bind Parameter.
  when i make the POST Request with JS it works however if i made it all in php it don't which i found kind of a strange ,here's an example . </p>
  
  <p>This the JS </p>
  
  <pre><code> var dataString="Name="+encodeURIComponent($("#name ."+Name[i]+"").val())+"&amp;Email="+encodeURIComponent($("#email ."+Name[i]+"").val());
  $.ajax({
      type: "POST",
      url: "sendback.php",
      data: dataString,
      cache: false,
      success: function(html)
      {
       }
      });
  </code></pre>
  
  <p>PHP Backend.</p>
  
  <pre><code>   foreach($_POST as $key =&gt; $value) {
      $Value=trim(urldecode($value));
         $stmt -&gt; bindParam(':'.$key.'',$Value);
      }
  </code></pre>
  
  <p>Result </p>
  
  <pre><code>---------------------------
  Name          |        Email 
  AAA           |email@exa.com
  ----------------------------
  </code></pre>
  
  <p>This Works and stores data correctly in the database </p>
  
  <p>However</p>
  
  <p>This Don't </p>
  
  <pre><code>$_POST['Name']="AAA";
  $_POST['Email']="email@exa.com";
  foreach($_POST as $key =&gt; $value) {
  $Value=trim(urldecode($value));
  $stmt -&gt; bindParam(':'.$key.'',$Value);
  }
  $stmt -&gt; execute();
  </code></pre>
  
  <p>Result</p>
  
  <pre><code>---------------------------
  Name          |        Email 
  email@exa.com |email@exa.com
  ----------------------------
  </code></pre>
  
  <p>It stores the values of the last $_post key in all the database columns . 
  So all the inputs to the database in this example would be "email@exa.com"
  after searching i found that to make the previous example works i need to add an "&amp;" before the "$value" in the loop,makes me wonder why it's different than the Ajax request,i mean they both POST requests,right?</p>