This tutorial will teach you the basics of using $_POST with PHP. You will learn how to process an HTML form and then apply your knowledge to a real example.

Specific requirements of this tutorial:
- Knowledge of HTML and <form>. If I say ‘make a form’ you should know what to do.
(it is assumed that you have all of the requirements specified earlier)
Briefing
Here are the tasks that you have to complete for this tutorial:
- Create a simple form (one input will do). Point the form’s action at another script that will print (echo) what the user entered in the input.
- Create a more set of inputs (6-7 inputs). Point the form’s action at another script that will print the values that the user entered like this: ‘field => value’. Ex: ‘name => Austin’;
- Modify your script for #2. This time use a loop to print all of the values.
If you have any questions regarding the tasks, please leave a comment.
Run Through/Hints
These should help you complete the task. If you feel that you don’t need this – stop reading. If you feel like you need it, it wouldn’t hurt to try things on your own first. :)
- The first task is fairly simple, so I can’t help you very much. This is all I got: The ‘name’ attribute of the input corresponds with the $_POST variable in PHP. For example,
<input type="text" name="XXXXXXX" />
would correspond with
$_POST['XXXXXXX']. This is case sensitive. - The second task is the same as the first, just repeated. Just keep in mind that things are case sensitive. If an input has the attribute
name="Email"and you try to use$_POST['email'], it won’t work. - The third task is a little more difficult. Just remember that $_POST is the same as any array, and likewise you can use foreach with it just as you would with any array. If you aren’t familiar with foreach, check this out.
I’ll post the solution to this problem soon. Good luck. :)