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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:43:40+00:00 2026-05-22T23:43:40+00:00

I have a big form. This form contains some inputs that can be duplicated

  • 0

I have a big form.

This form contains some inputs that can be duplicated by the user.

So they can choose for example how many Claimants have worked on a song and enter some fields for EACH claimant, with a limit of 10 Claimants.

The form will look like this (I will show only 3 now)

echo "<form action=\"\" id=\"submForm\" name=\"submForm\" method=\"get\">";
//1 CLAIMANT
echo "<p><span class=\"labelInput\">".(_t('_cR_name_mandatory'))." </span><input id=\"nameClaimant\" name=\"nameClaimant[]\" value=\"\" type=\"text\" class=\"required commonInput\"></p>"; 
echo "<p><span class=\"labelInput\">".(_t('_cR_DOB_mandatory'))." </span><input id=\"DOBClaimant\" name=\"DOBClaimant[]\" value=\"\" type=\"text\" class=\"required littleInput\"></p>"; 
echo "<p><span class=\"labelInput\">".(_t('_cR_company'))." </span><input id=\"companyClaimant\" name=\"companyClaimant[]\" value=\"\" type=\"text\" class=\"commonInput\"></p>"; 

//2 CLAIMANT
echo "<p><span class=\"labelInput\">".(_t('_cR_name_mandatory'))." </span><input id=\"nameClaimant\" name=\"nameClaimant[]\" value=\"\" type=\"text\" class=\"required commonInput\"></p>"; 
echo "<p><span class=\"labelInput\">".(_t('_cR_DOB_mandatory'))." </span><input id=\"DOBClaimant\" name=\"DOBClaimant[]\" value=\"\" type=\"text\" class=\"required littleInput\"></p>"; 
echo "<p><span class=\"labelInput\">".(_t('_cR_company'))." </span><input id=\"companyClaimant\" name=\"companyClaimant[]\" value=\"\" type=\"text\" class=\"commonInput\"></p>"; 

//3 CLAIMANT
echo "<p><span class=\"labelInput\">".(_t('_cR_name_mandatory'))." </span><input id=\"nameClaimant\" name=\"nameClaimant[]\" value=\"\" type=\"text\" class=\"required commonInput\"></p>"; 
echo "<p><span class=\"labelInput\">".(_t('_cR_DOB_mandatory'))." </span><input id=\"DOBClaimant\" name=\"DOBClaimant[]\" value=\"\" type=\"text\" class=\"required littleInput\"></p>"; 
echo "<p><span class=\"labelInput\">".(_t('_cR_company'))." </span><input id=\"companyClaimant\" name=\"companyClaimant[]\" value=\"\" type=\"text\" class=\"commonInput\"></p>"; 
echo "<input type=\"submit\" class=\"submBttnClass\" id=\"buttSubm\" name=\"buttSubm\" value=\"".(_t('_cR_submit_button'))."\">"; 
echo "</form>"; 

When the user submits the form I use a jQuery serialize function (I am on jQuery 1.3.2)

echo "<script type=\"text/javascript\">
$(document).ready(function() {
 $('#submForm').validate({   
  submitHandler: function(form) {
  var serialized = $('#submForm').serialize()
  $.get('".$site['url']."modules/yobilab/copyright/classes/DO_submission.php', serialized);
  //alert($('#submForm').serialize());
    window.setTimeout('location.reload()', 8000);
return false;
  form.submit();    
  } 
})

The problem is that the file that processes the Insert in the Database uses a foreach(I will show you my entire foreach with all the inputs that are passed with the serialize function:

if(!empty($_GET['nameClaimant'])){
$nameClaimant = $_GET['nameClaimant'];
$DOBClaimant = $_GET['DOBClaimant'];
$companyClaimant = mysql_real_escape_string($_GET['companyClaimant']);
$emailClaimant = $_GET['emailClaimant'];
$mainPhoneClaimant = $_GET['mainPhoneClaimant'];
$alternatePhoneClaimant = $_GET['alternatePhoneClaimant'];
$mobilePhoneClaimant = $_GET['mobilePhoneClaimant'];
$percentageClaimant = mysql_real_escape_string($_GET['percentageClaimant']);
$addressClaimant = mysql_real_escape_string($_GET['addressClaimant']);
$ZIPClaimant = $_GET['ZIPClaimant'];
$countryClaimant = $_GET['countryClaimant'];
foreach ($nameClaimant as $valueClaimant) {
$insClaim = "INSERT INTO cR_Claimants SET memberID ='".$memberID."', ParentSubmission='".$refNumb."', Name ='".mysql_real_escape_string($valueClaimant)."', DOB='".$DOBClaimant."', Company='".$companyClaimant."', Email='".$emailClaimant."', Address='".$addressClaimant."', ZIPcode ='".$ZIPClaimant."', Country='".$countryClaimant."', MainPhone='".$mainPhoneClaimant."', OtherPhone='".$alternatePhoneClaimant."', MobilePhone='".$mobilePhoneClaimant."', OwnershipPercentage='".$percentageClaimant."'";
$resultinsClaim=mysql_query($insClaim) or die("Error insert Claimants: ".mysql_error());
}
}

The foreach inserts in the database wrong stuff. It shows Array instead of the right value.

I would like to insert the info in the database consequentially with my foreach.

So for Claimant1 will insert its relative info

for Claimant2 will insert its relative info and so on.

It is not working. What am I doing wrong?

I know it is a little boring, but please help me! Lets play with it. You are All great
Thank you

I have attached what is doing in the database to let you see

You will see that is also creating empty strings in the database.

Why is that taking also empty values?

Please help me.
database_issue

  • 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-22T23:43:40+00:00Added an answer on May 22, 2026 at 11:43 pm

    this happens beacuse in the form name you called it with an array style name="key[]"

    So you can’t put into the SQL $key because $key at this point is an array.

    Also the correct INSERT syntax is INSERT INTO table (cols) VALUES (values)

    Addendum

    Also I think your form convetions it’s pretty bad. I suggest you to go with something like this:

    CLAIMANT1
    Email: <input name="claimant[0][email]" />
    Name: <input name="claimant[0][name]" />
    
    
    CLAIMANT2
    Email: <input name="claimant[1][email]" />
    Name: <input name="claimant[1][name]" />
    

    This way all your code is simplified into:

    foreach($_POST['caimant'] as $k=>$v) {    //> PSEUDOCODE
     INSERT INTO table VALUES ($v['email'],$v['name']);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that has a big form page and about half of
I have put a form on a web page where the user can send
I have a big form This form is processed by a PHP file called
I have a big form, that will be serialized by a jQuery function. The
I have a big form that is split over 3 pages (each page is
I have a pretty big data entry form which has many text fields ,
I have a search form that looks like this: The code behind the form
I have a big form on my site. When the users fill it out
Using GMP on c, I have a big integer mpz_t n in decimal form,
I have big system that make my system crash hard. When I boot up,

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.