Saturday, September 25, 2010

GET AND POST METHODS

Hi.. Today i am here to present u methods in php.

normally methods means orderly arrangement, elucidation, development, or classification.There are two ways the browser client can send information to the web server.
  • The GET Method
  • The POST Method
GET Method:

The GET method sends the encoded user information appended to the page request.

In other words GET methods is unprotected way to our query string.

  • The GET method is restricted to send upto 1024 characters only.
  • GET can't be used to send binary data, like images or word documents, to the server.
The PHP provides $_GET associative array to access all the sent information using GET method.

POST Method:

The POST method transfers information via HTTP headers. The information is encoded as described in case of GET method and put into a header called QUERY_STRING.

  • The PHP provides $_POST associative array to access all the sent information using GET method.
  • The POST method does not have any restriction on data size to be sent.
Example:

     echo "You are ". $_POST['age']. " years old.";      exit();   } ?> 

$_REQUEST variable:

The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.

The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.

Example:

echo "You are ". $_REQUEST['age']. " years old.";      exit();   } ?> 

No comments:

Post a Comment