Re: using BOTH GET and POST in the same page.
| From: | Paul M Foster | Date: | Mon, 14 Feb 2011 21:32:27 +0000 |
| Subject: | Re: using BOTH GET and POST in the same page. | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-311285@lists.php.net to get a copy of this message | ||
On Mon, Feb 14, 2011 at 12:30:56PM -0500, tedd wrote:
> >At 11:58 PM -0500 2/13/11, Paul M Foster wrote:
> >On Sun, Feb 13, 2011 at 02:25:45PM -0500, tedd wrote:
> >
> > > At 10:53 AM +0530 2/12/11, Ashim Kapoor wrote:
> > > >Dear All,
> > > >
> > > >I am reading "PHP5 and MySQL Bible". Chapter 7 of the book says
> >that PHP can
> > > >use GET and POST in the SAME page! Also it says that we can use
> the SAME
> > > >variables in GET and POST variable sets and that conflict
> >resolution is done
> > > >by variable_order option in php.ini Can some one write a small
> program to
> > > >illustrate the previous ideas? It is not clear to me as to how
> >to implement
> > > >this.
> > > >
> > > >Many thanks,
> > > >Ashim.
> > >
> > > Ashim:
> > >
> > > What others have not addressed is that the form used to send
> > > variables will send only GET OR POST method variables, but not both
> > > at the same time.
> >
> >-snip-
> >
> >It sounds like you're saying this isn't possible, yet it is. So what am
> >I missing? Is there an error in my code?
> >
> >Paul
> >
> >--
> >Paul M. Foster
> >http://noferblatz.com
>
>
> Paul:
>
> What I am saying is your form is a POST-method-form and it will only
> send variables via the POST method. If you change the form's method
> to GET, then the variables from the form will be sent via the GET
> method.
>
> Remember, there is ONLY ONE form being used per Submit action -- it
> can either be a POST method or a GET method, but it can not be both.
>
> This does not mean that you can't send both POST and GET variables
> together via the same Submit action, but it does mean that the *form*
> will only send it's contents via one method or the other.
>
> Here's a demo:
>
> http://php1.net/c/post-get
>
> Please note that the POST method form will send only POST data and
> the GET method form will send only GET data. However, you can force a
> POST method *form* via the action attribute value to also include a
> GET variable (see Submit POST w/GET) -- BUT -- that does not come
> from the form's input but rather from the action attribute. Do you
> see what I mean?
>
> The code is shown.
Understood. It sounded like you were saying you could only get back POST
or GET values from a page, which isn't true. The form itself, yes, can
only have one or the other method attribute.
>
> Also, please note interaction between the GET/POST/REQUEST re the
> variable 'alfa' and you will get an idea of why REQUEST may pose a
> problem.
This is why I don't use the REQUEST variable.
Paul
--
Paul M. Foster
http://noferblatz.com