FORM and 3 buttons. How to make goto URL

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
phpuse
Forum Newbie
Posts: 1
Joined: Tue Apr 13, 2010 6:14 am

FORM and 3 buttons. How to make goto URL

Post by phpuse »

There is a FORM, INPUT type="text". And there are three buttons. Kindly ask you to help with this: after you put some info to the form, you push one button and you go to one URL. If you push another button, you go to different URL. And if you push the third button you go to the third different URL. But the info for this goto is taken from the INPUT type="text" form. It is 5-7 figures that are added to the URL after "?". It looks like that: http://www.somesite.com/archive.php?idx= and here is the info from the form.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: FORM and 3 buttons. How to make goto URL

Post by omniuni »

What is your form Action and Method?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: FORM and 3 buttons. How to make goto URL

Post by AbraCadaver »

phpuse wrote:There is a FORM, INPUT type="text". And there are three buttons. Kindly ask you to help with this: after you put some info to the form, you push one button and you go to one URL. If you push another button, you go to different URL. And if you push the third button you go to the third different URL. But the info for this goto is taken from the INPUT type="text" form. It is 5-7 figures that are added to the URL after "?". It looks like that: http://www.somesite.com/archive.php?idx= and here is the info from the form.
You have two choices that I can think of:

First, each button needs an onclick that calls a javascript function passing the proper URL. The function needs to set the form action to the URL passed by the button and then submit.

Second, since it looks like you are using get instead of post, you can submit to one PHP page that collects the form data and then redirects to the proper page based upon which submit button was clicked (name).
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply