Re: Directing form to different handlers?
| From: | Robert Cummings | Date: | Mon, 01 Jun 2009 03:08:52 +0000 |
| Subject: | Re: Directing form to different handlers? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-293404@lists.php.net to get a copy of this message | ||
On Mon, 2009-06-01 at 12:53 +1000, Angus Mann wrote:
> Hi all. I realize this is more an HTML question than PHP but I'm sure someone here can
> help.
>
> I have several forms with lots (dozens) of text inputs. If the user presses the
> "Update" button I want the form handled by "update.php" but if they press
> "Delete" it needs to be handled by "delete.php" or "add.php" and so-on
> depending on the button they press.
>
> But when establishing the form I can only have <form method="POST"
> action="delete.php"> or "add.php" or whatever.
>
> Is there a way to direct the content of the form do a different handler depending on the
> button?
>
> I know I can use javascript to direct to a constructed URL and append
> ?name=smith&address=hishouse&telephone=28376.....and so on but this is not practical when
> there are dozens of entries....the URL becomes massive. I prefer to use "POST" and then
> use PHP to extract the POST array.
>
> Any ideas?
Yes, have the form submit to the URL that presented the form. Have THAT
PHP script determine which button was clicked. Then delegate to the
appropriate handler function.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP