470,848 Members | 972 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

How to load different pages from the same form

Suppose to have a PHP page with a form (method=post) and inside it two
text field and two buttons.

I would like to pass the two text fields to the page1.php if is pushed
the first button and to the page2.php if is pushed the second button.

Can someone help me?

Thank you from Franco in Italy
Jul 17 '05 #1
3 2451
Nel
"Franco Fellico'" <ff******@inwind.it> wrote in message
news:d8**************************@posting.google.c om...
Suppose to have a PHP page with a form (method=post) and inside it two
text field and two buttons.

I would like to pass the two text fields to the page1.php if is pushed
the first button and to the page2.php if is pushed the second button.

Can someone help me?

Thank you from Franco in Italy


On form page

<form name="form1" action="process.php" method="post">
<p>
<input type="text" name="textfield">
<input type="text" name="textfield2">
</p>
<p>
<input type="submit" name="submit" value="Yes">
<input type="submit" name="submit" value="No">
</p>
</form>
file: process.php
________________________
<?php
if ($_POST['submit'] == "Yes") { inclue("yes.php"); }
else { include("no.php"); }
?>

Nel
Jul 17 '05 #2
Franco Fellico' wrote:
Suppose to have a PHP page with a form (method=post) and inside it two
text field and two buttons.

I would like to pass the two text fields to the page1.php if is pushed
the first button and to the page2.php if is pushed the second button.

Can someone help me?

Thank you from Franco in Italy


Hi,

Nel described the serverside solution.
You can also handle this clientside by changing the action-attribute of the
form, like this:

document.forms["yourFormNameHere"].action="phpscript2.php";

You have to create an eventhandler of course that changes the action
appropriately.

Drawback is that you expect the visitors to have JS activated, so I think
you better follow Nel's suggestion which always works.

Regards,
Erwin Moller
Jul 17 '05 #3
Erwin Moller <si******************************************@spam yourself.com> wrote in message news:<41***********************@news.xs4all.nl>...
Franco Fellico' wrote:
Suppose to have a PHP page with a form (method=post) and inside it two
text field and two buttons.

I would like to pass the two text fields to the page1.php if is pushed
the first button and to the page2.php if is pushed the second button.

Can someone help me?

Thank you from Franco in Italy


Hi,

Nel described the serverside solution.
You can also handle this clientside by changing the action-attribute of the
form, like this:

document.forms["yourFormNameHere"].action="phpscript2.php";

You have to create an eventhandler of course that changes the action
appropriately.

Drawback is that you expect the visitors to have JS activated, so I think
you better follow Nel's suggestion which always works.

Regards,
Erwin Moller


THANK YOU NEL AND ERWIN, IT WORK! I ADOPTED THE SERVER SIDE SOLUTION,
BUT THANK YOU ALSO FOR THE CLIENTSIDE SUGGESTION.
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Dave B | last post: by
5 posts views Thread by N | last post: by
9 posts views Thread by John Kirksey | last post: by
2 posts views Thread by Smoothice | last post: by
1 post views Thread by Magdelin | last post: by
9 posts views Thread by netasp | last post: by
3 posts views Thread by Kojikabutosv | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.