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 8230475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:08:59+00:00 2026-06-07T17:08:59+00:00

I am experiencing some issues with a form I am making. I have the

  • 0

I am experiencing some issues with a form I am making. I have the code to post a form to my PHP script that is meant to handle the data with this code:

<script type="text/javascript">
 $(document).ready(function()
 {
  $("#submit").click(function() 
  {
   var q1 = $("#q1").val();
   var q2 = $("#q2").val();
   var answers = "page=1&q1="+q1+"&q2="+q2;

   $.ajax({
    type:'POST',
    url:'add.php',
    data:answers,
    success:function(response)
    {
     $("#answers").html(response);
    }
   });
  });       
 });
</script>

This form is then received in my PHP script like this:

$page = $_POST['page'];
$q1 = $_POST['q1'];
$q2 = $_POST['q2'];
echo "Page: " .$page . "<br/>Question 1: " . $q1 . "<br/>Question 2: " . $q2;

The issue of it all is that I want this form to be able to handle X amount of inputs and also handle input I do not know the name of. Like I can get 5 textboxes, or 2 textboxes + a string of radiobuttons and so on. Is there a way to collect ALL $_POST data and then explode it or something similar so I can get it ready for the database? I wish to recover all question id’s(values) and all answer values(could be a string or an int representing a radiobutton id).

  • 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-06-07T17:09:01+00:00Added an answer on June 7, 2026 at 5:09 pm

    First: Let jQuery build your data string, your current method requires you to know each field in advance and can’t handle data with special characters in it.

    url:'add.php',
    data: $('#myForm').serialize(),
    success:function(response)
    

    Second: Name your fields using the PHP multiple fields with the same name convention:

    <input type="radio" name="answer[1]" value="foo">
    <input type="radio" name="answer[1]" value="bar">
    

    You can then access them as:

    $_POST['answer'][]
    

    It is an array, so you can get the ‘1’ and the ‘foo’ or the ‘bar’ in a loop.

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

Sidebar

Related Questions

we have a customer that's been experiencing some blocking issues with our database application.
I have an upload form that uploads mp3s to my site. I have some
I'm experiencing some issues with the footer of my website I'd like to have
Some reasons i am experiencing this issue on my website. When the website loads
I'm currently experiencing some problems with my server. I have a pool which is
I am experiencing some problem on UTF-8 Encoding. I have a CSV file and
I'm experiencing some problems with breaking my code to reusable parts using templates and
I'm experiencing some problems while trying to read a binary file in C. This
I'm experiencing some issues with rewriting my blocking socket server to a non-blocking version.
After experiencing some performances issues on my client side, we decided to give a

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.