PHP

PHP WEB CONCEPTS

PHP WEB CONCEPTS

Before the information is sent by the browser it is encoded with the help of a scheme called URL encoding. Here the name/value pairs are joined with equal signs and the different pairs are separated by the ampersand. For example-

name1=value1&name2=value2&name3=value3

in this, we remove the spaces with the help of character + and the nonalphanumeric characters are replaced by the hexadecimal values. Once the information is encoded it is sent to the server.

There are two ways to send the information to the web server by the browser client.

The GET Method- In this method the encoded user information is appended to the page request. To separate the page and the encoded information the character? is used.

http://www.test.com/index.htm?name1=value1&name2=value2

 Characteristics of Get Method.

  • it produces a long string that can be found in the browser's location: box in the server logs.
  • It is restricted to send upon 1024 characters.
  • If you want to send a password or other sensitive information to the server never use the get method.
  • We can’t use it to search binary data such as images or word documents to the server. 
  • We can access the data sent by the Get method by using the QUERY_STRING environment variable.
  • To access all the sent information the associative array  $_GET is provided to PHP. 
  1. The post method 

In this method, an HTTP header is used to transfer information. The information is encoded similarly as in the case of the Get method and is put into a header called QUERY_STRING.

  • They don’t have any restrictions on the data size that is to be sent. 
  • They are used to send both ASCII as well as binary data. 
  • As the data sent is gone through the HTTP header its security depends upon the HTTP protocol. By using this secure HTTP you can be sure that the information is secure.
  • The associative array $_POST is used to access all the sent information.

The $_REQUEST variable 

This variable contains the contents of both the $_GET, $_POST, and $_COOKIE variable. This variable is used to send data from both the Get and Post method.