2 forms, 1 html file

General discussions related to php

Moderators: macek, egami, gesf

Wopkeuh
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Sep 27, 2003 1:02 pm

2 forms, 1 html file

Postby Wopkeuh » Sat Sep 27, 2003 1:36 pm

I have 2 forms on a single HTML file.. When clicking on the submit button which is with the first form, the action of the 2nd form is executed.

I looked it up on the internet and I found out that it's impossible to use multiple forms in 1 file when using certain browsers. So I downloaded the latest version of IE. Now I'm surprised to find out it still doesn't work..

My question is: "Is there a way to make multiple forms in 1 page work?"

BTW.
I also tried submitting the 1st form using "get". The strange thing was that the form was sending the right data (as seen in the adress bar), but the html file was interpreting the data of the 2nd form.

I sincerely hope one of you can make anything out of this.

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Re: 2 forms, 1 html file

Postby swirlee » Sat Sep 27, 2003 9:28 pm

Wopkeuh wrote:I looked it up on the internet and I found out that it's impossible to use multiple forms in 1 file when using certain browsers.


I'd be interested to know where you found this bit of info, because it's completely false. Well, not completely, but it may be said that no modern browser has any trouble with multiple forms on a single page.

That said, there are a couple of things you can do to keep the browser from getting confused. First, make sure your form is closed. Start your form with <form action=...> and end it with </form>. Make sure none of the first form is between the second form's tags and vice versa. If you happen to be designing this form with Dreamweaver or the like, this is a likely culprit, but it's something to watch out for regardless. Second, in order to test your theory, try giving your submit buttons different names, e.g. give the first form a submit button <submit name="form1_submit"> ad your second form a submit button <submit name="form2_submit"> and then check to see which one was clicked.

Those are all of my suggestions for now. This is an odd problem, but not one that should be too difficult to sort out.

Wopkeuh
New php-forum User
New php-forum User
Posts: 2
Joined: Sat Sep 27, 2003 1:02 pm

Re: 2 forms, 1 html file

Postby Wopkeuh » Sun Sep 28, 2003 12:20 am

swirlee wrote:Second, in order to test your theory, try giving your submit buttons different names,


That one did the trick. Thanks.

You won't ever catch me making a mistake like that again ;)


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron