I am new to this forum and I help some help. I'm doing a class project. If someone could help me finish it up would be appreciated. I am completely lost now.
Professors instructions
In the summary page I need to show
A. The number of rentals entered
B. Total Amount of all rentals entered
C. Percentage of rentals which were high end models (luxury, minivan, suv)
D. Percentage of rentals selected as least one "extra - dvd ,cd, satellite ,GPS.
My php script so far:
<?php
session_start();
if (!(isset($POST['first_time']))) {
$SESSION['cnt'] = 0;
$_SESSION['fin'] = 0;
}
if (isset($_POST['submit'])) {
// Address error handling
// Get the values from the $POST array:
$firstname=$POST['firstname'];
$lastname=$POST['lastname'];
$deposit=$POST['deposit'];
$days=$POST['days'];
$beginningmileage=$POST['beginningmileage'];
$endmileage=$POST['endmileage'];
$ins=$POST['coverage'];
$discount=$POST['discount'];
$drivers=$POST['drivers'];
$model=$POST['model'];
$under25=$POST['age'];
$gastank=$POST['gas'];
$gallons=$POST['galllons'];
$features=$_POST['features'];
// Validate the firstname
if(empty($POST['firstname'])) {
print '<p> Please enter your first name.</p>';
$okay= FALSE;
}
// Validate the lastname
if(empty($POST['lastname'])) {
print '<p> Please enter your last name.</p>';
$okay= FALSE;
}
// Validate the days
if (is_numeric($_POST['days'])) {
//Check that days is greater then 0.
if ($_POST['days']< 1) {
print '<p> You must enter days greater then 0</p>';
$okay= FALSE;
}
}
else {
print '<p> Number of days are not numeric</p>';
$okay= FALSE;
}
//Calculate the total:
$daily= $model $days;
$mileage= ($endmileage-$beginningmileage-($days100)).35;
if ($mileage<0)
$mileage=0;
$drivers=($drivers-1)5$days;
$sub= $daily+$mileage+$drivers+features;
$coverage=$sub.1$ins;
$tax= $sub 0.05;
$tot=0;
foreach ($features as $charge){
$tot=$tot+$charge;
}
$extra=$tot*$days;
$fin=$sub+$coverage+$tax+$extra-$deposit;
$fin=$fin-($fin$discount);
$daily=number_format($daily,2);
print "daily:$$daily<br/>";
$mileage=number_format($mileage,2);
print "mileage:$$mileage<br/>";
/print "mileage chargeprin:<br/>
/
$drivers=number_format($drivers,2);
print "drivers:$$drivers<br/>";
$underdrivers=$under25$days;
if ($gastank=="E"){
$gascharge=$gallons3;}
else{$gascharge=$gallons3;}
$sub=number_format($sub,2);
print "extra:$$extra<br/>";
print "discount:$discount<br/>";
print "sub:$$sub<br/>";
$coverage=number_format($coverage,2);
print "coverage:$$coverage<br/>";
$fin=number_format($fin,2);
print "fin:$$fin<br/>";
$SESSION['cnt'] = $SESSION['cnt'] + 1;
$SESSION['fin'] = $SESSION['fin'] + $fin;
print '<form method="post" action="Test2.php">
<p><input name="rentals" value="Enter New Rental" type="submit"></p>
<p><input name="finish" value="Complete All Rentals" type="submit"></p>
<input type="hidden" name="first_time" value="true">
</form>';
}
else
{
if (isset($POST['finish'])) {
print "summary form here is the count " . $SESSION['cnt'];
print "total amount of all rentals" . $_SESSION['fin'];
}
else {
?>
<!DOCTYPE html
<head>
</head>
<body>
<div><p>Complete this form for rates:</p>
<form action="" method="post">
<php?
<p>First Name: <input type="text" name="firstname" size="20" /></p>
<p>Last Name: <input type="text" name="lastname" size="20" /></p>
<p>Initial Deposit: <input type="text" name="deposit" size="20" /></p>
<p>Number of Days Rental: <input type="text" name="days" size="3" /></p>
<p>Beginning Mileage: <input type="text" name="beginningmileage" size="10" /></p>
<p>Ending Mileage: <input type="text" name="endmileage" size="10" /></p>
<p>Insurance: <select name="coverage">
<option value="1">Yes</option>
<option value="0">No</option>
</select></p>
<p>Customer Type;
<select name="discount">
<option value="0">Retail</option>
<option value=".1">Preferred</option>
<option value=".15 ">Corporate</option>
<select></p>
<p>Number of Drivers: <select name="drivers">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
<option value=8>8</option>
</select></p>
<p>Choose Model: <select name="model">
<option value="20">Subcompact</option>
<option value="25">Compact</option>
<option value="30">Mid-Size</option>
<option value="40">Luxury</option>
<option value="80">Minivan</option>
<option value="60">SUV</option>
</select></p>
<p>Under 25?: <select name="age">
<option value="0">0</option>
<option value="2.50">1</option>
<option value="5.00">2</option>
<option value="7.50">3</option>
</select></p>
<p>Gas tank: <select name="gas">
<option value="E">Bring it empty</option>
<option value="F">Bring it full</option>
<p>Number gallons: <input type="text" name="gallons" size="3" /></p>
<input type="hidden" name="first_time" value="true">
<p> Extra Features;
<input type="checkbox" name="features[]" value="5.00"/>DVD Player
<input type="checkbox" name="features[]" value="10.00"/>Multi-CD/MP3 Player
<input type="checkbox" name="features[]" value="3.00"/>Satellite Radio
<input type="checkbox" name="features[]" value="5.00"/>GPS
<input type="submit" name="submit" value="Submit Form" />
?>
</form>
</div>
</body>
</html>
<?php
}
}
?>
Thanks for any help.