This form may be used to insert multiple set of data. Multiple set of records can be inserted at a single click in the “Submit” button. This is highly efficient in the case of bulk data entry. Here is a set of jQuery and PHP code which will perform as per the requirement.

To implement the code you have to activate jQuery first. Then you have to include the “lzmultiform” jQuery plugin (two files the .js and .css) and initialize it on document load for the form you want to activated it for. This plugin will create an interface on top of the form, by which user will be able to increase the number of field sets.

You have to place a table containing the form fields and their labels inside the form. The plugin will clone this table as per user requirement. Please go through the following code:

$msg ” : “”?>

Name :
Email :
Address :

Now while you are done with the HTML part you have to receive the POSTed data and insert it into the database. To do this simply write the following code and it’s complete.

include "lzmfpost.php";

// insert into database if user submits the form with data
if(isset($_POST['submit']))
{
	$sql = "INSERT INTO `lz_multiform`.`user` (`name`,`email`,`address`) VALUES " . createFormSqlValues() . ";";

	if(mysql_query($sql,$conn))
		$msg = "Records added successfully.";
	else
		$msg = "Sorry! failed to add the records";
}

If user types in any number into the field before the “Extend” button and clicks the button, then it will add more field sets multiplied by the input number into the form. Now if he/she skips some of the sets it will automatically manage the fault.

Comment here, if you get into any problem using this or if you have some better idea behind it. Thank you for visiting this blog. Come soon to get more.


Download Source Code

, , , ,
  • http://www.comcubetechnologies.in/ Comcube Technologies Calicut

     

    Thanks for this beautiful information. It’s worth
    reading. Love to see your blog!