INPUT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>David Goodwin Cents Calcualtion</title>
<link href="main.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.auto-style1 {
border: 1px solid #000080;
background-color: #C0C0C0;
}
.auto-style2 {
text-align: left;
}
</style>
</head>
<body bgcolor="#C0C0C0">
<h1>Welcome to David's Cents Calculation Page</h1>
<?php if (!empty($error_message)){ ?>
<p class="error"><?php echo $error_message; ?></p>
<?php } ?>
<p> </p>
<form action="DavidGoodwin_CentsCalculationProcess.php" method="post" style="text-align: center">
<table class="auto-style1" style="width: 55%">
<tr>
<td style="width: 282px">Pease enter number of dimes:</td>
<td class="auto-style2">
<form method="post">
<input name="Text1" type="text" value="<?php echo $dimes; ?>" /></form></td>
</tr>
<tr>
<td style="width: 282px">Please enter number of quarters:</td>
<td class="auto-style2">
<form method="post">
<input name="Text2" type="text" value="<?php echo $quarters; ?>" /></form></td>
</tr>
<tr>
<td style="width: 282px">
<form method="post">
<input name="Submit" style="width: 147px; height: 41px" type="submit" value="Calculate" /></form></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
RESULTS PAGE
<?php
// get the data from the form
$quarters = $_POST['quarters'];
$dimes = $_POST['dimes'];
// validate
if ( empty($dimes) ) {
$error_message = 'Dimes is a required field.';
} else if ( !is_numeric($dimes) ) {
$error_message = 'Dimes must be a valid number.';
} else if ( $dimes <= 0 ) {
$error_message = 'Dimes must be greater than zero.';
}
if ( empty($quarters) ) {
$error_message = 'Quarters is a required field.';
} else if ( !is_numeric($quarters) ) {
$error_message = 'Quarters must be a valid number.';
} else if ( $quarters <= 0 ) {
$error_message = 'Quarters must be greater than zero.';
}
// if an error message exists, go to the index page
if ($error_message != '') {
include('Basics.php');
exit();
}
//calculate for the total number of cents
$quarters = 25;
$dimes = 10;
$total = ($quarters + $dimes);
//formatting
$quarters_f = number_format($quarters, 0);
$dimes_f = number_format($dimes, 0);
$total_f = number_format($total, 0);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="en-us" http-equiv="Content-Language"/>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>DavidGoodwin Cents Calculation</title>
<style type="text/css">
.auto-style1 {
text-align: center;
}
.auto-style2 {
border: 1px solid #000080;
}
</style>
<link href="main.css" rel="stylesheet" type="text/css"/>
</head>
<body bgcolor="#C0C0C0">
<h1 class="auto-style1">Total Cents</h1>
<table class="auto-style2" style="width: 100%">
<tr>
<td style="width: 383px">Total cents in quarters:</td>
<td><?php echo $quarters; ?></td>
</tr>
<tr>
<td style="width: 383px">Total cents in dimes:</td>
<td><?php echo $dimes; ?></td>
</tr>
<tr>
<td style="width: 383px">Total all together:</td>
<td><?php echo $total; ?></td>
</tr>
</table>
<p class="auto-style1"> </p>
</body>
</html>

New Topic/Question
Reply



MultiQuote






|