|
|
 |
| PHP Programming Basics -
iHostcafe.com |
|
|
| Getting
Started With Forms - |
|
| This section will introduce
you to PHP and using it with forms. The primary direction of this lesson
is to allow you to connect to a database, and insert data. The most common
way to initiate that connection is through forms. |
One of the most powerful
features of PHP is the way it handles HTML forms.
The basic concept that is important to understand is that any form element
in a form will automatically result in a variable with the same name as
the element being created on the target page. This probably sounds confusing,
so here is a simple example. Assume you have a page with a form like this
on it:
<form action="action.php3" method="POST">
Your name: <input type=text name=name>
You age: <input type=text name=age>
<input type=submit>
</form> |
There is nothing special about this
form. It is a straight HTML form with no special tags of any kind. When
the user fills in this form and hits the submit button, the action.php3
page is called. In this file you would have something like this:
Hi <?php echo $name?>. You are <?php echo $age?> years old. |
It should be obvious what this does.
There is nothing more to it. The $name and $age variables are automatically
set for you by PHP. |
| |
| PREVIOUS
- NEXTPAGE
|
|
 |
|