Amazon.com: PC Books || Educational Software || Magazines
Amazon: Books-CA || Software-CA || Books-UK || Software-UK

HTML | Javascript | ASP | PHP | VBScript | SQL | Hardware | PC FAQ| WinXP|

Learn to Build, Upgrade, or Repair your Computer Ebook + PC Safety 101 kwwebservice.com Reasonably priced web development & hosting
PHP Basics
Introduction
Variables & Arrays
Sub & Functions
If Statements
Case Statements
Loop Statements
Date Objects
Form Processing
Text File Objects
Database Access
Adding Record
Updating Record
Deleting Record
Virtual Includes
Cookies
Session
Server Variables
Creating Login Page
E-mail
PHP Books @
CA Amazon
UK Amazon
US Amazon

  :: Home
PC Topics
  :: Build A PC
  :: Windows XP
  :: PC Help
Tutorials
  :: HTML
  :: JavaScript
  :: ASP
  :: PHP
  :: VBScript
  :: SQL
Miscellaneous
  :: Code/Scripts
  :: Forum
  :: Links
  :: Contact us
  :: Tell A Friend
  :: In Somali
  ::
Web Articles
  Top Web Hosting
Reviews
  Processing
Online Card Payment Guide
  Domain name
registration & buying guide
  Getting
a website online guide
  Search Engine
submission & optimization tips
Netfirms Web Hosting
Free trial
Quality business correspondence.
Yahoo! Search Marketing


Processing forms using PHP

You can process HTML forms using these two powerful PHP functions, $_REQUEST[] and $_POST[].  $_POST[] retreives value passed through form object. $_REQUEST retrieves values from url passed variable value or value passed through form object.  Take a look at the following example:
<form name="userForm" method="post" action="userForm.php">
  Enter a user name: <input type="text" name="userName" size="20">
  Enter a password: <input type="password" name="password" size="20">
  <inpute type="submit" name="submit" value="Send">
</form>
Result

Enter a user name:

Enter a password:

We just created HTML form and tell the browser to process the form using the file "userForm.php".  The following is userForm.php file that writes the values from the form.
<html>
<head>
<title>Process form Info</title>
</head>
<body>
<?php
print "You typed username: $_POST[userName]<br>";
print "and the password: $_REQUEST[password]";
?>
</body>
</html>
Type something in the text boxes and hit submit button to see the result of this example.  What you will see is the result of this code.   We use both $_POST[] & $_REQUEST[] for illustration.

PHP HTML Form Processing Example 2

You can store value retrieved from form into variables in order to use these value whatever way you want.  Take a look at this example which is little bit more complex then previous one. It uses combination of checkbox, radio buttons, text fields, and text box:
<html>
<head>
<title>Form Example 2</title>
</head>
<body>
<p><b>This example process basic form elements</b>
<form method="POST" action="formProcess.php">
<p>Your name: <input type="text" name="Name" size="20"><br>
Status: <input type="radio" value="Customer" name="status">Customer   <input type="radio" name="status" value="Visitor">Visitor<br>
Do you own any of these trucks:<br>
<input type="checkbox" name="truck[]" value="Land Cruiser">Land Cruiser<br>
<input type="checkbox" name="truck[]" value="Sequoia">Sequoia<br>
<input TYPE="checkbox" name="truck[]" value="4Runner">4Runner<br>
<input TYPE="checkbox" name="truck[]" value="Highlander">Highlander<br>
<input TYPE="checkbox" name="truck[]" value="Tundra Access Cab">Tundra Access Cab<br>
Car of Choice:<select size="1" name="car">
<option value="MR2 Spyder">MR2 Spyder</option>
<option value="Celica">Celica</option>
<option value="Matrix">Matrix</option>
<option value="Avalon">Avalon</option>
<option value="Camry">Camry</option>
<option value="Corolla">Corolla</option>
<option value="Echo">Echo</option>
<option value="Prius">Prius</option>
<option value="RAV4 EV">RAV4 EV</option>
</select><br>
Enter some general comments about what you think about Toyota cars:<br>
<textarea rows="5" name="comment" cols="50"></textarea><br>
<align="center"><input type="submit" value="Submit" name="submit"><br>
</form>
</body>
</html>
Code for formProcess.php
<html>
<head>
<title>Result of your information</title>
</head>
<body>
<?php
$name=$_POST["Name"];
$status=$_POST["status"];
$car=$_POST["car"];
$comments=$_POST["comment"];
$truck=$_POST["truck"];
print "Your name: <b>$name</b><br>";
print "Status: <b>$status</b><br>";
print "Your favourite car is: <b>$car</b><br>";
print "You currently own these trucks:<br>";
foreach($truck as $t) { echo "<b>".$t."</b><br />";
} print "Your comments about Toyota products:<b>$comments";
?>
</b>
</body>
</html>

This example process basic html form elements by php script

Your name:
Status: Customer Visitor
Do you own any of these trucks:
Land Cruiser
Sequoia
4Runner
Highlander
Tundra Access Cab
Car of Choice:
Enter some general comments about what you think about Toyota cars:


To test this form, type some information and click the submit button.

Loops File Objects
Bluehost.com Web Hosting $6.95
PC System Tools
SpyCleaner
Registry Mechanic
4Diskclean Pro
Health PC Club
TweakNow
Registry Washer
SpyAnyWhere
System Lifeguard
...More/Details

PC Articles
  Computer Safety
prevent viruses & Spyware