|
Posted by J.O. Aho on 12/21/06 10:34
pu wrote:
> Hi
>
> I have the following code and wish for the Save button to be sent to another
> form.
> echo "<form action=self.php method=post>";
> echo "<input type=submit name=submitclient value='Get Client'>";
> echo "<input type=submit name=submitsender value='Get Sender'>";
> echo "<input type=submit name=submitsave value='SAVE'>";
> How do I post the form values to a separate save form, say, savedata.php,
> instead of self.php, if I click the SAVE button?
There are two methods you could try to use
1. You use javascript to change the from-tags action value with the OnClick
script.
2. You let self.php check for the $_REQUEST['submitsave'] and then redirect
to savedata.php (don't forget to forward the request values too).
Another method would be to have a wrapper script (we call it wrapper.php),
then set the form to load that page on all submits.
<form action="wrapper.php" method="post">
In the wrapper page you then check for which submit button has been used and
include the right page.
if(isset($_REQUEST['submitclient']) && $_REQUEST['submitclient']=='Get Client') {
require_once('self.php');
} else if(isset($_REQUEST['submitsender']) && $_REQUEST['submitsender']=='Get
Sender') {
require_once('self.php');
} else if(isset($_REQUEST['submitsave']) && $_REQUEST['submitsave']=='SAVE') {
require_once('savedata.php');
} else {
header("Location: http://www.example.net");
}
This allows you to keep the scripts simple where you don't have to think so
much about the other possible submits.
--
//Aho
Navigation:
[Reply to this message]
|