In the next part of the course we are going to be discussing how to process HTML form data using PHP. The concepts explored here are very important because web pages interact with users using Forms.
Form data can be used for many things.
Form processing starts as soon as we fill out an HTML form and click the submit button.
At this stage in the course you should be familiar with creating HTML forms. We know that the
<form> element, has an action attribute.
In our html course, we did just about everything, except assign a value to our action attribute. It's the action that brings our form to life.
The action of our form will point to a PHP script. In addition to instructing our server on what to do with the form data, the PHP script can also validate the form. This means, we can check things like email addresses or phone numbers to make sure they are in the right format. We can also check to make sure that form inputs are not left empty, or put limits on how much data can be inputted. These are just a few examples.
PHP validation cannot be turned off, making it the safest way to test form inputs for data accuracy.
We will be exploring two ways to transmit form data to our PHP script from our HTML form. The Get method and Post method.
In both methods, the data is transmitted in an array that is automatically generated. The array holds the key/value pairs. The keys are the name of the form controls and the value is the data inputted by the user. We will come back to this when we start creating our form.
There are some important points to note about POST vs. GET before we begin:
The POST method passes variables using the HTTP POST method.