Re: [PHP] using BOTH GET and POST in the same page.
At 4:32 PM -0500 2/14/11, Paul M Foster wrote: 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. What it sounded like was: 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. I still stand by that statement. A form can only send variables through the method stated in the form. The "action" value of the form is not data provided by a POST-method form -- it simply uses the address provided by the coder. If you want to add GET data to the action value, then that's your call, but the POST method form will do nothing to the action value data. However, a GET-method form will change the action value. Try this as an experiment. Use a GET form with the action value containing get type data (?id=1234) and see what happens to that data. If you do, then you'll have a better idea of what you can/can't do with a form. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using BOTH GET and POST in the same page.
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using BOTH GET and POST in the same page.
At 10:31 PM -0500 2/13/11, Robert Cummings wrote: On 11-02-13 02:25 PM, 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. Using REQUEST will show the values of the variables sent, but will not show what method was used (not addressing COOKIE) and that is the reason why it's not the best idea to use REQUEST. Furthermore, as you point out, conflict resolution is done in accordance with variable order as set in the php.ini file and that can be different between different environments. As such, a script can act differently and there in lies the problem. Now, I have used scripts that may receive POST or GET variables and act accordingly, but you will never (except possibly AJAX) have a situation where a script will receive both sets of variables at the same time. So, I don't think one can write a small simple script that can demonstrate this. This is terribly wrong... any drupal site (or probably any front controller based CMS) will use GET variables to route to the correct page which may have a form which will capture the POSTed data. I've seen POST and GET often in the same page. Cheers, Rob. Rob: Understood, but that is not what I am addressing. A form can only send data it has collected via it's declared method and the choices are POST or GET, but not both. Please review the post I made to Paul on this subject -- that explains this concept better. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using BOTH GET and POST in the same page.
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
Re: [PHP] using BOTH GET and POST in the same page.
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. > > Using REQUEST will show the values of the variables sent, but will > not show what method was used (not addressing COOKIE) and that is the > reason why it's not the best idea to use REQUEST. > > Furthermore, as you point out, conflict resolution is done in > accordance with variable order as set in the php.ini file and that > can be different between different environments. As such, a script > can act differently and there in lies the problem. > > Now, I have used scripts that may receive POST or GET variables and > act accordingly, but you will never (except possibly AJAX) have a > situation where a script will receive both sets of variables at the > same time. So, I don't think one can write a small simple script that > can demonstrate this. I'm sure I must be misunderstanding something here. The following is a script which will show both GET and POST being received by the script, and with the same variable names but different values: =-=-=-=-=-=-=-=-=- \n"; print_r($_GET); print "\n"; print "POST:\n"; print_r($_POST); ?> =-=-=-=-=-=-=-=-=-= Call this script via test.php?alfa=1234 Call it the first time this way and leave that in the location bar of your browser. Now fill in the value in the blank with the value 4567. Press the "submit" button. You will see that $_POST['alfa'] returns 4567, while $_GET['alfa'] returns 1234. 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using BOTH GET and POST in the same page.
On 11-02-13 02:25 PM, 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. Using REQUEST will show the values of the variables sent, but will not show what method was used (not addressing COOKIE) and that is the reason why it's not the best idea to use REQUEST. Furthermore, as you point out, conflict resolution is done in accordance with variable order as set in the php.ini file and that can be different between different environments. As such, a script can act differently and there in lies the problem. Now, I have used scripts that may receive POST or GET variables and act accordingly, but you will never (except possibly AJAX) have a situation where a script will receive both sets of variables at the same time. So, I don't think one can write a small simple script that can demonstrate this. This is terribly wrong... any drupal site (or probably any front controller based CMS) will use GET variables to route to the correct page which may have a form which will capture the POSTed data. I've seen POST and GET often in the same page. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using BOTH GET and POST in the same page.
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. Using REQUEST will show the values of the variables sent, but will not show what method was used (not addressing COOKIE) and that is the reason why it's not the best idea to use REQUEST. Furthermore, as you point out, conflict resolution is done in accordance with variable order as set in the php.ini file and that can be different between different environments. As such, a script can act differently and there in lies the problem. Now, I have used scripts that may receive POST or GET variables and act accordingly, but you will never (except possibly AJAX) have a situation where a script will receive both sets of variables at the same time. So, I don't think one can write a small simple script that can demonstrate this. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] using BOTH GET and POST in the same page.
On 2/11/2011 9:23 PM, 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. But basically, the short of it is this. Name: When submitted with data to this: Will result in this: Array ( [page_id] => 22 [action] => AddUser ) Array ( [action] => DelUser [FullName] => Jim Lucas ) Array ( [page_id] => 22 [action] => DelUser [FullName] => Jim Lucas ) Check out the example that I wrote here http://www.cmsws.com/?page_id=5 Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] using BOTH GET and POST in the same page.
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.