Chris Bell Chris Bell 'A business that makes nothing but money is a poor business.'
- Henry Ford

About Me >>   Bachelor's Degree >>   IT-370 Web Server Design

SNHU - IT-370 Web Server Design
Written by: Chris Bell - March, 2014

Basic HTML Form to PHP Script

 

What is your favorite color?



Favorite Color:  

($_GET)

 

What is your favorite color?



Favorite Color:  

($_POST)



This basic HTML form asks the user for their favorite color. When the Submit button is clicked the form is sent to a PHP script that uses the user's input (favorite color). If you type GREEN into either box above the PHP script will have a sentence prepared such as, "Your favorite color is ____!" The script will fill in the blank space with your favorite color. This is a good way to create Mad Lib games for practicing PHP skills. You can use for easy-to-use widgets and tools that can be added to your website functionality. I practiced with Mad Libs, math games, calorie counting, mortgage formulas and more here:

Chris Bell Website PHP Projects

($_GET)

This is called a Super Global (http://php.net/superglobals.php) used to read the user's input and bring it to the next page. When you type in GREEN the Super Global it holds "GREEN" in the URL and uses it on the next page whenever asked upon. In this case I used the Super Global twice; once when I filled in the blank of "Your favorite color is GREEN" and again when I changed the color of the font to GREEN. If you type in BLUE the font will change to blue, so I used the Super Global in two spots.

($_POST)

I'm not an expert, however I can tell you that there is VERY little difference between these two super globals. The POST global doesn't use the URL to hold the input, everything is defined on the PHP script page. If you want to know which super global to use for your coding, I recommend using the POST global because expert coders can see, and use, the code within the URL. Remember, using the GET global puts the input into the URL, using the POST global does not.