Jump to content

does a page support more than one form?


voodoochicken

Recommended Posts

i have placed two forms in the same page, something like echo "<form action=\"action1.php\" method=\"post\">"; echo "text1: <input type=\"text\" name=\"val1\" />"; echo "text2: <input type=\"text\" name=\"val2\" />"; echo "<input type=\"submit\" />";(make aside the echos)and another like echo "<form action=\"action2.php\" method=\"post\">"; echo "<input type=\"submit\" />";since those are two separate forms, and each has its own submit, i would expect that if i click the button on the first form it will go to action1, and if i click on button of second form it will go to action2 page, but both buttons go to page1, any pointers?

Link to comment
Share on other sites

<form action="action1.php" method="post">	text1: <input type="text" name="val1" />	text2: <input type="text" name="val2" />	<input type="submit" /></form><form action="action2.php" method="post">	text1: <input type="text" name="val1_form2" />	text2: <input type="text" name="val2_form2" />	<input type="submit" /></form>

Note the change in Actions and also the change of the name values on each form.

Link to comment
Share on other sites

but both buttons go to page1, any pointers?
You might have forgotten the closing </form> tag.
Link to comment
Share on other sites

You can have more then one form on one page, but you can't have one form inside another form. The first form needs to end before the second form starts. If you want some more info about processing forms with PHP check the PHP tips topic inside the PHP forum.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...