Daniel Kats
Daniel Kats

Reputation: 5554

Working with multiple forms at once in PHP

I need to make an application which dynamically generates some number of forms and processes them. The user should be able to deal with each form individually without resetting the entered values in the other forms.

What I have right now is a master form that uses JS to generate some number of forms. The forms are all the same (i.e. I iterate on include("myForm.php").

My problem is that every time I submit one form, the values in the other forms get reset. How do I fix this?

Upvotes: 1

Views: 459

Answers (2)

George Cummins
George Cummins

Reputation: 28906

This is a three-step process:

  1. Ensure that each form element on the page has a unique name and ID.
  2. Store submitted values in the user's session.
  3. Use PHP to insert the previously-entered values into the form fields when a form is posted.

Upvotes: 1

Jesse van Assen
Jesse van Assen

Reputation: 2290

Post the form with AJAX, this doesn't refresh the page so you won't lose the values entered in the other forms

Upvotes: 1

Related Questions