Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

Start Learning Now

Our free lessons will get you started (Flash® 10 required).
Get immediate access to our entire library.

Sign up for Educator.com

Features Overview

  • Get on-demand access to our complete library
  • Search and jump to exactly what you need to learn
  • Track your progress
  • Download practice and lesson files
  • *Ask questions and get answers from our community & instructors

HTTP & the POST Method

  • HTTP request and HTTP response messages are compsed of two parts, which are separated by a blank line:
    • a message header
    • a message body
  • HTTP request headers have a required first line followed by an optional number of what are known as HTTP headers. The first line must contain the HTTP method, the requested URI, and the HTTP version. An example HTTP request header containing the Host HTTP header is:
    GET /index.html HTTP/1.1
    Host: www.educator.com
  • HTTP response headers have a required first line followed by an optional number of HTTP headers. The first line must contain the HTTP version, HTTP status code, and phrase describing the status code. An example HTTP response message (both header and body) is:
    HTTP/1.1 200 OK
    Date: Wed, 3 Aug 2011 23:59:59 GMT
    Content-Length: 31
    Content-Type: text/html
    [blank line]
    <html><body>Hello</body></html>
  • header() allows you to manually add HTTP headers to the HTTP response generated by your PHP script, and it must be called before ANY output from a PHP script has been generated (if output buffering is Off).
  • The GET method works by appending any data to the URL via a query string. The POST method rather includes submitted data in the body of the HTTP request. By default, POST data is URL-encoded, just as for a query string. Here is an example of a POST request containing data:
    POST /contactUs.php HTTP/1.1
    Host: store.educator.com
    Date: Wed, 3 Aug 2011 23:59:59 GMT
    Content-Length: 39
    Content-Type: application/x-www-form-urlencoded
    [blank line]
    name=Joe+Smith&email=jsmith@hotmail.com
  • POST data is accessed from PHP using the $_POST superglobal.
  • The GET method is typically used for simple resource requests or performing a query/search. The POST method is typically reserved for idempotent requests, or requests that have no side-effects.
  • Additional Resources:

HTTP & the POST Method

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

Advanced PHP Training with MySQL