RE: [PHP] multiple submit buttons
| From: | Dave VanAuken | Date: | Wed, 20 Dec 2000 19:05:56 +0000 |
| Subject: | RE: [PHP] multiple submit buttons | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-31290@lists.php.net to get a copy of this message | ||
SUBMIT is a button that when pressed submits the form. You can use the
VALUE attribute to provide a non- editable label to be displayed on the
button. The default label is browser-specific. If a SUBMIT button is
pressed in order to submit the form, and that button has a NAME attribute
specified, then that button contributes a name/value pair to the submitted
data. Otherwise, a SUBMIT button makes no contribution to the submitted
data.
Thus my previous code submission:
<FORM name=frmSubmit METHOD="POST">
<INPUT type=text name=text1>
<INPUT type="submit" name="Submit" value="Submit">
<INPUT type="submit" name="Cancel" value="Cancel">
</FORM>
At the top of the page I say:
<?
if ($Submit) #might be better to check ifset
{
// do something to submit the page
}
else if ($Cancel)
{
// redirect to calling page
}
?>
-----Original Message-----
From: news [mailto:news@darkstar]On Behalf Of "Jason"
Sent: Wednesday, December 20, 2000 2:08 AM
To: php-general@lists.php.net
Cc: php-general@lists.php.net
Subject: Re: [PHP] multiple submit buttons
like i said, news to me. i remeber when experiementing with a similar
solution quite a while ago that PHP never seeing the the variable(s)
appended to the script name when doing a post. possibly it was php3, my
browser, or usage, who knows. but if it works, i can't argue with that.
> I've been passing variables like that in my posts for over a year!
>
> It certainly does work and that exact piece of code I posted is working
> beautifully.
>
> All my FORM's are METHOD="POST".
>
> The POST variables come from the FORM itself. What you put in the action
> certainly is stored as HTTP_GET_VARS.
>
>
> > -----Original Message-----
> > From: Jason [mailto:jbeebe@op480.com]
> > Sent: Wednesday, 20 December 2000 16:51
> > To: samantha@cfs.net.au; Toby Butzon; php-general@lists.php.net
> > Subject: Re: [PHP] multiple submit buttons
> >
> >
> > wont work. you cannot pass get variables in a post action. if you can
its
> > news to me.
> >
> > i am under the impression that the submit button is the default button
> > right? so if someone simply hits enter you want it to pick
> > submit. if thats
> > the case do this:
> >
> > if (!isset($submit) || $submit == "submit") {
> >
> > /// this tests to see if submit is set to submit OR if submit was
> > never set
> > at all
> > /// if it was never set and the script was ran, then obviously
> > the user hit
> > enter
> > /// and if they hit enter, they want the default action, which is this
one
> > }
> > else {
> > /// if submit wasn't set as submit, and submit was set, then it
> > obvious was
> > set to cancel
> > /// so do something here
> > /// to be more precise you could do else if ($submit == "Cancel"), its
all
> > the same
> > }
> >
> >
> >
> > ----- Original Message -----
> > From: Samantha Savvakis <samantha@cfs.net.au>
> > To: Toby Butzon <php-lists@imawebdesigner.com>;
> > <php-general@lists.php.net>
> > Sent: Tuesday, December 19, 2000 11:35 PM
> > Subject: RE: [PHP] multiple submit buttons
> >
> >
> > >
> > > I think what I'm doing to do is this:
> > >
> > > Set the action of the form to "somepage.php?submitpage=true"
> > >
> > > Then test for Cancel first if it finds the submitpage variable is
set.
> > >
> > > <?
> > > if ($submitpage == "true")
> > > {
> > > if ($submit == "Cancel")
> > > {
> > >
> > > // detect if cancel first.
> > > file://The cancel button requires navigation to get to it
> > > }
> > > else
> > > {
> > > // The only way it could get here is to click the submit button
> > > }
> > > }
> > > ?>
> > >
> > > Sound like a plan?
> > >
> > > > -----Original Message-----
> > > > From: Toby Butzon [mailto:php-lists@imawebdesigner.com]
> > > > Sent: Wednesday, 20 December 2000 16:22
> > > > To: samantha@cfs.net.au; php-general@lists.php.net
> > > > Subject: Re: [PHP] multiple submit buttons
> > > >
> > > >
> > > > 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?
> > > >
> > > > Toby Butzon
> > > > [ criticism spurs improvement ]
> > > >
> > > >
> > > > ----- 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
> > >
> >
> >
> > --
> > 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
>
--
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