One submit button for 3 forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hellboy83
Forum Newbie
Posts: 5
Joined: Wed Nov 26, 2008 9:05 am

One submit button for 3 forms

Post by hellboy83 »

Hi Guys,

I have a situation in here regarding forms.

I have 3 different forms, each one with it's own MySQL table
to be filled by a single user but instead of having 3 submit buttons for each form i want to have
one submit button for all the 3 forms.

In other words:
After filling the third form the user hits submit button and it sends the data on the first, second and third form to
each correspoding table.

How can i structure this?
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: One submit button for 3 forms

Post by papa »

One form divided by <br /> tags.
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

Re: One submit button for 3 forms

Post by deejay »

you'll need to have mutiple INSERT queries.

jsut filter everything you've got in $_POST into the write tables.

you may need mysql_insert_id(); if you want table ids to go into any following tables.

I hope that helps.
hellboy83
Forum Newbie
Posts: 5
Joined: Wed Nov 26, 2008 9:05 am

Re: One submit button for 3 forms

Post by hellboy83 »

Ok i agree with you papa

But it's gonna be a huge scrolling from the top to the bottom of the browser since my forms are huge. Is there any way of breaking that one form in partes?

Part 1 Part 2, etc etc
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: One submit button for 3 forms

Post by watson516 »

hellboy83 wrote:Ok i agree with you papa

But it's gonna be a huge scrolling from the top to the bottom of the browser since my forms are huge. Is there any way of breaking that one form in partes?

Part 1 Part 2, etc etc
If you broke it up into parts, would that not be the same thing as having the user fill out 3 different forms? If you do the parts idea, you could replace the submit button with a 'Part 2' image and some javascript that submits the form. Deal with that first 'part' and then show the second part.

Or, you could do something like having one giant form but put each 'section' into it's own div and using javascript hide the current section and display the next.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: One submit button for 3 forms

Post by John Cartwright »

What I would do is have a single form, and use javascript to toggle between what div is displayed, and thus hidding the others. If the user did not have javascript enabled, it would allow you to degrade gracefully and just show all the forms at once.
Post Reply