Re: newbie with php/HTML/HTTP question

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

 



On Sun, Apr 27, 2008 at 5:44 PM, Rod Clay <rclay@xxxxxxxxxxxxxxx> wrote:
> I've written my php script to accept either:
>
>  1) url parameters, when first invoked (so in this case I'm getting
> variables out of the $_GET global array), but then I create a form with
> method=PUT and, when this form is submitted and comes back into this same
> php script, I'm looking for
>
>  2) variables in the $_PUT global array
>
>  However, I tested this just now and, for some reason I can't fathom, though
> the form I create has method=PUT, when it is submitted and comes back to my
> php script, $_SERVER['REQUEST_METHOD'] still contains "GET".
>
>  Am I missing something fairly obvious here (quite possible!!)?
>
>  Once my php script is invoked with parameters in the url (i.e., implicit
> GET method), am I not able to create a form with method=PUT and have this
> form come back into my php script with values in the $_PUT global array??
>
>  Thanks for any help anyone can give me!  I'm stumped!
>
>  Rod Clay
>  rclay@xxxxxxxxxxxxxxx

First off, I don't think browsers support sending form data via PUT
(unless you use the XmlHTTPRequest calls usually used for AJAX
requests), so regardless of whether you specify method="put" in your
form tag, the request is still sent via GET. I suspect that basically
the browsers say that if the attribute equals "post" then send via
POST; otherwise send via GET. As I understand it, the PUT method is
for sending a document to be stored at the requested URI. As such, a
PHP script couldn't really be handling a PUT request because if the
URI for the script exists, the content in the PUT request should
replace the content of the URI. (I guess technically you might be able
to swing it through something with mod_rewrite where a PHP script
could handle the logic of storing (PUT) or retrieving (GET) the
document.)

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6

"The fundamental difference between the POST and PUT requests is
reflected in the different meaning of the Request-URI. The URI in a
POST request identifies the resource that will handle the enclosed
entity. That resource might be a data-accepting process, a gateway to
some other protocol, or a separate entity that accepts annotations. In
contrast, the URI in a PUT request identifies the entity enclosed with
the request -- the user agent knows what URI is intended and the
server MUST NOT attempt to apply the request to some other resource.
If the server desires that the request be applied to a different URI,
it MUST send a 301 (Moved Permanently) response; the user agent MAY
then make its own decision regarding whether or not to redirect the
request."


Secondly, there isn't a $_PUT superglobal in PHP.

http://us3.php.net/manual/en/reserved.variables.php



Andrew

-- 
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