Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7049579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:02:05+00:00 2026-05-28T03:02:05+00:00

I have two html text input fields and two buttons. The first button saves

  • 0

I have two html text input fields and two buttons.

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.

<input type="text" id="field1" name="field1" />
<input type="text" id="field2" name="field2" />
<button id="notizeValues">Notize</button>
<button id="sendToServer">Save</button>

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

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);
});
});

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

isset($_POST['values']){
    $values = json_decode($_POST['values'], true);

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

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:02:06+00:00Added an answer on May 28, 2026 at 3:02 am

    $.post() doesn’t JSON-encode variables sent to the server – so the json_decode call in PHP is unnecessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html form with two input fields, in first one user puts
I have a form with two input fields, one text and one send button.
I have four input fields two text and two hidden. The HTML: <input type=text
I have two HTML input fields article and url . How to duplicate field
I got two simple input text fields in a HTML form: <input type=text name=data[User][name]
I have two <input> fields with the HTML attribute size=20 . This displays fine
I have two text boxes t1 and t2 in an html page. I'd like
I have two html pages, when you click on something on the first html,
I've got this HTML form where I have multiple input elements: text, radio, and
I have a form with two input fields and a tag cloud. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.