0

I am new to PHP. I have a stupid question and need your explanation.
When I make a POST request with the cURL command-line:

curl -d "username=admin&password=admin&submit=Login" --dump-header headers http://localhost/Login

Please kindly let me know what is the purpose of this command-line. I just wonder whether data "username=admin&password=admin&submit=Login" will be attached to url http://localhost/Login. Then, we have:

http://localhost/Login/username=admin&password=admin&submit=Login

Is it correct?

1 Answer 1

1

HTTP POST is a method of sending data as an arbitrary package. This is done in the http protocol, the POST data is sent in the "body", not the URL.

HTTP GET is different, and it's GET that sends the data (restricted) in the URL.

Therefore, in your example, the request will look (in a very simplified way) something like this:

POST /Login HTTP/1.1
Host: localhost
Content-Length: 42
username=admin&password=admin&submit=Login

The last line of this example is the body, whose length is specified in the HTTP header "Content-Length".

Here is an easy reference to show you the difference of POST and GET:
http://www.w3schools.com/tags/ref_httpmethods.asp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.