Logo         Community
The Company
Your Account
Contact Us
PHP 101 (part 2): Calling All Operators
Use PHP to process Web forms, and get to grips with operators and conditional statements.

| ...And Function |

Now for the other half of the puzzle: the message.php script. This script reads the data submitted by the user and "does something with it". Here is message.php:


// retrieve form data
$input = $_POST['msg'];
// use it
echo "You said: <i>$input</i>";


When you enter some data into form.htm (let's say "Boo"), and submit it, the form processor message.php will read it and display it to you ("You said: Boo"). Thus, whenever a form is submitted to a PHP script, all variable-value pairs within that form automatically become available for use within the script, through a special PHP container variable: $_POST. You can then access the value of the form variable by using its "name" inside the $_POST container, as I did in the script above.

Obviously, PHP also supports the GET method of form submission. All you need to do is change the "method" attribute to "get", and retrieve values from $_GET instead of $_POST. The $_GET and $_POST variables are actually a special type of PHP animal called an array, which I'll be teaching you about shortly. Don't worry too much about it at the moment, just make sure you're comfortable with retrieving simple values from a form with PHP, and then scroll on down to learn about some more operators that are useful in this context.

How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!

previous page more like this  print this article  next page
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
In cut!...
American Chai
The Core
Find out how you can use this article on your own Web site!

Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback