ICS 325
Lab 6
Form
Processing With PHP
(Linux Redhat 7.1)
1.
Display
a users Name.
§
Log
onto "redhat.ics.metrostate.edu" using your class account, then do
the following:
$ cd
$ cd public_html
$ mkdir lab6
$ cd lab6
§
Edit
an HTML document called "getName.php" using pico with the following
lines:
<?php
/*****************************************
Author: Your
Name
Date: Current
Date
Description:
This script asks
for a users name then
after they press
the Submit button their
name is displayed
at the top of the screen.
Variables:
$name The value passed from the user
name entry from the form
*****************************************/
?>
<html>
<head>
<title>A form processing
site</title>
</head>
<body>
<?php
if
(isset($submit)){
echo "<h1>Hello
$name</h1>";
}
?>
<form
name="getName" method="post" action="<? $PHP_SELF
?>">
Enter
your Name:
<input
type="text" name="name" value="Enter Name
Here"><br />
<input
type="submit" name="submit"
value="Submit"><br />
</form>
</body>
</html>
§
Invoke
IE 5 on your machine, and check your html file with the following address:
http://redhat.ics.metrostate.edu/~f04325??/lab6/getName.php
2.
Process
a form and display a workorder.
§
Log
onto "redhat.ics.metrostate.edu" using your class account, then do
the following:
$ cd
$ cd public_html
$ cd lab6
§
Edit
an HTML document called "myStore.php" using pico with the following
lines:
<?php
/*****************************************
Author: Your
Name
Date: Current
Date
Description:
*****************************************/
define("LABOR",50);
?>
<html>
<head>
<title>My
Computer Workshop.com</title>
</head>
<body>
<h1>Welcome
to My Computer Workshop</h1>
<?php
if(isset($submit)){
?>
<h3>Billing
Invoice</h3>
<table
width="600" border="0">
<tr>
<td
align="left" width="50%"><?=$fName?>
<?=$lName?></td>
<td
align="right" width="50%">My Computer
Workshop</td>
</tr>
<tr>
<td
align="left" width="50%"><?=$address?> </td>
<td
align="right" width="50%">Metropolitan State
University</td>
</tr>
<tr>
<td
align="left" width="50%"><?=$city?>,
<?=$state?> <?=$zip?></td>
<td
align="right" width="50%">Saint Paul Campus</td>
</tr>
<tr>
<td
align="left" width="50%"><?=$phone?> </td>
<td
align="right" width="50%">Information and Computer
Science
Department</td>
</tr>
</table>
<h3>Detailed
Work Description</h3>
<table
width="500" border="0">
<?php
$total=0;
echo
"<th width=50% align=left>Work</th><th width=50%
align=right>Cost</th>";
if
($modemType != "none"){
$tempTotal=0;
echo "<tr>";
echo "<td width=80%
align=left>Installation of $modemType
modem
</td>";
$tempTotal = $modemHours * LABOR;
echo "<td width=20%
align=right>$tempTotal</td>";
$total = $total + $tempTotal;
echo "</tr>";
}
if
($memoryAmount != "none"){
$tempTotal=0;
echo "<tr>";
echo "<td width=80%
align=left>Installation of $memoryAmount
MB
of Memory </td>";
$tempTotal = $memHours * LABOR;
echo "<td width=20%
align=right>$tempTotal</td>";
$total = $total + $tempTotal;
echo "</tr>";
}
if
($officeApp != "none"){
$tempTotal=0;
echo
"<tr>";
echo "<td width=80%
align=left>Installation of $officeApp</td>";
$tempTotal = $officeHours * LABOR;
echo "<td width=20%
align=right>$tempTotal</td>";
$total = $total + $tempTotal;
echo "</tr>";
}
if ($osType != "none"){
$tempTotal=0;
echo "<tr>";
echo "<td width=80%
align=left>Installation of $osType
Operating
System</td>";
$tempTotal = $osHours * LABOR;
echo "<td width=20%
align=right>$tempTotal</td>";
$total
= $total + $tempTotal;
echo "</tr>";
}
echo
"<th width=80% align=left>Total</th><th width=20%
align=right>
$
$total</th>";
echo
"</table>";
} else { // submit button not yet clicked
?>
<h3>Please
Fill Customer Information</h3>
<form
name="orderForm" action="<? $PHP_SELF ?>"
method="post">
<table>
<tr>
<td>First Name: </td>
<td
colspan="2"><input type=text name="fName"
id="fName"
size="30" /></td>
<td>Last
Name: </td>
<td
colspan="2"><input type=text name="lName"
id="lName"
size="30" /></td>
</tr>
<tr>
<td>Address: </td>
<td
colspan="5"><input type=text name="address"
id="address"
size="80" /></td>
</tr>
<tr>
<td>City:
</td>
<td><input
type=text name="city" id="city" size="20"
/></td>
<td>State:
</td>
<td><input
type=text name="state" id="state" size="5"
/></td>
<td>Zip
Code: </td>
<td><input
type=text name="zip" id="zip" size="20"
/></td>
</tr>
<tr>
<td>Phone:
</td>
<td colspan=3><input type=text
name="phone" id="phone"
size="40"
/></td>
<td colspan="2" />
</tr>
</table>
<h3>Please Enter Repair Information -
Round to the Nearest Hour</h3>
<table>
<tr>
<th
align="left">Install New Modem</th>
<td>Modem Type: </td>
<td>
<select
size="1" name="modemType" id="modemType">
<option
value="none">*** Please Select ***</option>
<option
value="US Robotics 56k">US Robotics 56k</option>
<option
value="ZOOM v.92 56k">ZOOM v.92 56k</option>
<option value="Create Labs
56k">Create Labs 56k</option>
</select>
</td>
<td>Labor
Hours: </td>
<td><input
type="text" name="modemHours" id="modemHours"
size="10"></td>
</tr>
<tr>
<th
align="left">Install Memory</th>
<td>Memory Amount: </td>
<td>
<select
size="1" name="memoryAmount"
id="memoryAmount">
<option
value="none">*** Please Select ***</option>
<option
value="64">64MB</option>
<option
value="128">128MB</option>
<option
value="256">256MB</option>
</select>
</td>
<td>Labor
Hours: </td>
<td><input
type="text" name="memHours" id="memHours"
size="10"></td>
</tr>
<tr>
<th align="left">Install Office
Application</th>
<td>Office
Application: </td>
<td>
<select
size="1" name="officeApp" id="officeApp">
<option
value="none">*** Please Select ***</option>
<option value="Microsoft
Word">MS Word</option>
<option value="Microsoft
Excel">MS Excel</option>
<option value="Microsoft Power
Point">MS Power Point</option>
<option
value="Microsoft Access">MS Access</option>
</select>
</td>
<td>Labor Hours: </td>
<td><input
type="text" name="officeHours" id="officeHours"
size="10"></td>
</tr>
<tr>
<th align="left">Install Operaring
System</th>
<td>Operating System</td>
<td>
<select
size="1" name="osType" id="osType">
<option
value="none">*** Please Select ***</option>
<option
value="Windows 2000 Pro">Windows 2000 Pro</option>
<option
value="Windows XP Home">Windows XP Home</option>
<option
value="Redhat Linux">Linux</option>
</select>
</td>
<td>Labor
Hours: </td>
<td><input
type="text" name="osHours" id="osHours"
size="10"></td>
</tr>
</table>
<h3>Please
Press Button to Get Work Order</h3>
<input
type="submit" value="Submit Work Order"
name="submit" />
</form>
<?php
}
?>
</body>
</html>
§
Invoke
IE 5 on your machine, and check your html file with the following address:
http://redhat.ics.metrostate.edu/~f04325??/lab6/myStore.php
Your data
input screen should look like this:

After you
fill out the form and click the Submit button, the screen should look something
like this:
