Re: using BOTH GET and POST in the same page.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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.

Cheers,

tedd

--
-------
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux