Post value pairs from jQuery to php file and save data in database
<p>I have two html text input fields and two buttons.</p>

<p>The first button saves the value pairs from the two input fields in an array.
The second button sends this array with all the input value pairs to a php file and the php file saves all these values in a database.
The user can input values so much as he can, there is no limit.</p>

<pre><code>&lt;input type="text" id="field1" name="field1" /&gt;
&lt;input type="text" id="field2" name="field2" /&gt;
&lt;button id="notizeValues"&gt;Notize&lt;/button&gt;
&lt;button id="sendToServer"&gt;Save&lt;/button&gt;
</code></pre>

<p>My question is, how can the server access this data? 
I am trying this:</p>

<pre><code>var values = [];
$('#notizeValues').click(function (){
   var value1 = $('#field1').val();
   var value2 = $('#field2').val();
   values.push({'value1': value1 , 'value2': value2 });   
});

$('#sendToServer').click(function (){
    var sendValues = values;
    $.post("achieveAdminAktion.php",{values:  sendValues },  function(data){
    $("#serverResponse").html(data);
});
});
</code></pre>

<p>Now comes the code of the php file, but I get the whole time errors.
For this solution I get an Warning: <code>json_decode() expects parameter 1 to be string, array given</code>
and errors in echo function:</p>

<pre><code>isset($_POST['values']){
    $values = json_decode($_POST['values'], true);

     foreach ($values as $json) {
         ....save value in database....
 }
    echo $values; // nothing
}
</code></pre>

<p>That is only one example of lot of examples I tried but nothing works.
How can I solve this problem?
How can I access these data in php file and how can I walk through the json-array and save al these value pairs in database.</p>
