Logo Your Web Hosting Solution
Line
PHP Documentation
Introduction
Variables
Using Forms
Sending Email
MySQL Databases
Tutorials Index
Home Page
PHP Tutorial - Using Forms

Forms allow you to gather information from your web site visitors. This section assumes you are already familiar with forms. All the usual .html form elements are available to PHP.

Sample Form

<form action="hello.php" method="POST">
Your first name <input type="text" name="name">
Your favorite color <input type="text" name="color">
<input type="submit" value="Send Info">
</form>

When the user completes the form and clicks the button, the data entered will be sent to hello.php.

hello.php

Hello <?php echo $_POST["name"]; ?>,
Your favorite color is <?php echo $_POST["color"]; ?>.

The $_POST["name"] and $_POST["color"] variables are set by PHP, allowing you to read and use their values.

The output

Hello Barney,
Your favorite color is purple.

The final output would be as above, if the person entered 'Barney' as their name and 'purple' as their favorite color.

The above sample use the POST form method. You can also use GET and then use the $_GET autoglobal.

PHP support is enabled on all web site hosting plans.

Top Of Page 
Line
Copyright© 1996 - 2024 Clockwatchers, Inc.