SHARED HOSTING
   RESELLER HOSTING
   VPS HOSTING
   SEMI-DEDICATED HOSTING
   DEDICATED HOSTING
   DOMAIN REGISTRATION
   MERCHANT ACCOUNTS
   AFFILIATE PROGRAM
 

Jun 20, 2008
Magento Hosting

May 26, 2008
Support for Zend Framework Hosting

 
   

View 3rd Party Uptime Stats
BBBOnline Reliability Seal
RatePoint Site Seal
Green Hosting
HACKER SAFE certified sites prevent over 99.9% of hacker crime.

A2 Hosting Uptime
hosting

A2 Hosting Guarantee
cheap web hosting
 
Dealing with Forms

Dealing with 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 will automatically be available to your PHP scripts. Please read the manual section on Variables from outside of PHP for more information and examples on using forms with PHP. Here is an example HTML form:

Example 2-6. A simple HTML form

<form action="action.php" method="post">
 <p>Your name: <input type="text" name="name" /></p>
 <p>Your age: <input type="text" name="age" /></p>
 <p><input type="submit" /></p>
</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.php page is called. In this file you would write something like this:

Example 2-7. Printing data from our form

Hi <?php echo $_POST['name']; ?>.
You are <?php echo $_POST['age']; ?> years old.

A sample output of this script may be:

Hi Joe. You are 22 years old.

It should be obvious what this does. There is nothing more to it. The $_POST['name'] and $_POST['age'] variables are automatically set for you by PHP. Earlier we used the $_SERVER autoglobal; above we just introduced the $_POST autoglobal which contains all POST data. Notice how the method of our form is POST. If we used the method GET then our form information would live in the $_GET autoglobal instead. You may also use the $_REQUEST autoglobal, if you do not care about the source of your request data. It contains the merged information of GET, POST and COOKIE data. Also see the import_request_variables() function.

You can also deal with XForms input in PHP, although you will find yourself comfortable with the well supported HTML forms for quite some time. While working with XForms is not for beginners, you might be interested in them. We also have a short introduction to handling data received from XForms in our features section.

 

Featured Packages:

Shared Hosting
Small Biz
250 GB Disk Space
250 GB of Data Transfer
Host UNLIMITED Domains
PHP 5.2.6
Apache 2.2
MySQL 5.0.x
PostgreSQL 8.2.x
Ruby on Rails 2.0
SSH/Shell
Subversion/CVS
cPanel
SSL, FTP, Stats
Free Auto-Install Blogs,
Forums, E-Commerce and more!

From $6.95/mo


Reseller Hosting
Starter Reseller
25 GB Disk Space
250 GB of Data Transfer
Host UNLIMITED Domains
PHP 5.2.6
Apache 2.2
MySQL 5.0.x
PostgreSQL 8.2.x
Ruby on Rails 2.0
SSH/Shell
Subversion/CVS
cPanel
SSL, FTP, Stats
Free Auto-Install Blogs,
Forums, E-Commerce and more!

From $17.95/mo

 
 
 
 
Home    About Us    Services    Support    Order Online    Contact    Privacy