Basic PHP
Advanced PHP
You should have already learnt how to write an HTML form before. As a revision, let's take a look at the following HTML form:
|
<html> <head> <title>HTML Form</title> </head> <body> <form action="ch03_01_login.php" method="get"> User Name: <input type="text" name="user" /><br> Password: <input type="password" name="pwd" /><br> <input type="submit" value="Login"/> </form> </body> </html> |
In this lesson, you will learn how to process the form data using PHP scripts.
How to get the form data depends on the method used in submitting the HTML form:
For example, to get the submitted user name and password of the sample form, the following PHP code can be used:
|
$userName = $_GET['user']; $password = $_GET['pwd']; |
If you do not care about the method used in submitting the form data, you can also use the $_REQUEST array variable. The $_REQUEST variable is an associative array that contains the contents of $_GET, $_POST and $_COOKIE. (We will discuss cookies in later lesson.)
Copyright © 2010. MyTutorialPlanet. All rights reserved.