Re: multiple submit buttons
| From: | Jason | Date: | Wed, 20 Dec 2000 06:43:40 +0000 |
| Subject: | Re: multiple submit buttons | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31165@lists.php.net to get a copy of this message | ||
> Not really an issue of what PHP doesn't realize, but more an issue of what
> IE doesn't send. Since you didn't click the button, it's just not setting
> the value.
>
> What if you added || $submit == "" to your if statement?
>
that would produce an error. if the variable $submit itself is never passed
you cannot evaluate it.
i think the best method would be what i described in the previous post, end
it with an else statement to handle all default posts.
you could also check before hand.
if (!isset($submit) || $submit == "Submit") {
// process submit page
}
else {
// jump to cancel page, of course you could also do else if ($submit ==
"Cancel") { but whats the diff =P
}
>
> ----- Original Message -----
> From: "Samantha Savvakis" <samantha@cfs.net.au>
> To: <php-general@lists.php.net>
> Sent: Wednesday, December 20, 2000 1:16 AM
> Subject: RE: [PHP] multiple submit buttons
>
>
> : Hi all,
> :
> : I know this thread is pretty old, but I have a few problems with
multiple
> : submit buttons and it annoys me that this problem occurs. I have posted
to
> : the PHP list about this before, but I'm wondering where the problem
> actually
> : lies.
> :
> : I have a page with 2 submit buttons, one for submit, one for cancel.
It's
> : pretty simple. A few text fields.
> :
> : <FORM name=frmSubmit METHOD="POST">
> : <INPUT type=text name=text1>
> : <INPUT type="submit" name="submit" value="Submit">
> : <INPUT type="submit" name="submit" value="Cancel">
> : </FORM>
> :
> : At the top of the page I say:
> :
> : <?
> : if ($submit == "Submit")
> : {
> : // do something to submit the page
> : }
> : else if ($submit == "Cancel")
> : {
> : // redirect to calling page
> : }
> : ?>
> :
> : Now, this all works fine if I actually move the mouse to the button and
> : click on it, or if I tab to the button itself and hit the enter key.
> :
> : But - this is where the problem is. If I have the cursor in the text
> field,
> : I hit the enter key (which enters on the default button),
$HTTP_POST_VARS
> : has no recollection of "submit" as a post variable. Hence, $submit has
no
> : value, hence none of the if/else statement actually works.
> :
> : I have this problem in IE browsers (since Netscape doesn't have a
default
> : button). Is there a fix for this? I thought PHP would be able to realise
> : that the page has submitted because of the default button and place it
> into
> : HTTP_POST_VARS.
> :
> : Any ideas?
> :
> : Sam
> :
> :
> : --
> : PHP General Mailing List (http://www.php.net/)
> : To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> : For additional commands, e-mail: php-general-help@lists.php.net
> : To contact the list administrators, e-mail: php-list-admin@lists.php.net
> :
> :
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>