Forgot Password / Register
Site Statistics
Total Members: 509
Total Tutorials: 242
Newsest User: Lestop
Todays Unique Hits: 204
0 Users 1 Guests Online

PHP Forms

The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts.

Example!
Code
<html>
<body><form action="index.php" method="post">
First Name: <input type="text" name="name" />
Real Age: <input type="text" name="age" />
<input type="submit" />
</form></body>
</html>


The example HTML page above contains two input fields and a submit button. When the user fills in this form and click on the submit button, the form data is sent to the "index.php" file.

The "index.php" file looks like this:

Code
<html>
<body>Hello <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old. Welcome to our website.</body>
</html>


A sample output of the above script may be:
Code
Welcome Joshua.
You are 25 years old. Welcome to our website
Joshua
Author:
Views:
1501
Rating:
There are currently no comments for this tutorial.