Use Programming Guides Wisely and Methodically

By: Jon Caldwell

PHP as a scripting language means it is designed to work with ease of use on web page designs. Such pages often require the user to input data which can then be treated as input to the various elements of the program that are contained within the script to obtain the desired result. The PHP $_Get and $_Post, are samples of variables that are used to obtain information from forms like the registration form on a membership page.

HTML forms and PHP work hand in hand together in such a way that any element in an HTML page is readily available to PHP scripts.

The sample page in the previous post contains two input fields that are name and age, when the user inputs the data and clicks on the submit button, the form's data is sent to the file "welcome.php" file. The resulting php file would look something like this:

Welcome.

You are years old

The output of the script we made would look like:
Welcome Ernie
You are 35 years old.

That would be an overview of the full potential of the $_GET and $_POST variables and they will be discussed in depth later as we go deeper into their functionality in PHP scripts.

As the previous post discussed, PHP is very easy to use with web pages for the language has all the elements of a web page as a useable element. Now, going forward, forms or pages are easily handled and checked on the user end, meaning when you open a page the data input is easier to verify on the user side rather than have the input sent back to the server for checking and then returning any errors should there be any. This reduces load on the server and network having the data validated on the user end, allowing the information to be sent when the form receives all correct input. This type of handling is called client side validation where the input page verifies itself only requesting for the next step in a process when it returns true (all entries are correct). This way, the error checking and return function is on the client side reducing network and server load.

The $_GET variable is an array of variable names with the corresponding values sent by the HTTP GET method. It is used to collect values from a form by using the method="get". All information sent by a form using this method is visible to all on the browser's address bar but it is limited to only 100 characters.

Take note that the variable contents and names are verbosely displayed so do not forget to take that into account when using the variable for forms processing.

The file "welcome.php" can now use the $_GET variable to obtain all the required information which is shown on the address bar. As it does that, all the name fields of the form will automatically be the ID keys in the $_GET array variable.

The variable is an array of variable names and values that is sent by the HTTP POST method. The $_POST variable is used to collect values from a form with the method="post". The information sent from a form through this method is invisible to others and has no limits with concerns to the amount of information to be sent.

Programming
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 

» More on Programming