Need a lil help in php understanding wht the hell im doing wrong

this is what im trying to do.

Create an HTML form to collect the following information regarding an automobile rental: Customer First and Last Name Initial deposit Number of days rental Beginning mileage Ending mileage Insurance or no insurance selected Number of drivers (at least one) Based on the information collected, calculate the final rental charge. The following information should be used to perform the calculation: Daily charge for car rental: $30 Each rental gets 100 miles free per day. Every mile over the free mileage is $0.35. If the customer selects insurance, the premium is 10% of the entire rental, including the mileage and driver charges. There is a driver charge of $5 per day for each driver – the first driver is free. The initial deposit should be moved from the final calculated charge that is displayed to the user. The final results should look something like:

and this is what ive done so far but i cant figure out how to correct all of this to save my life…

Welcome to this page! <?php // week 2

//int variable

First: Last:

Number of Days:

Deposit:

Start Milage:

End Milage:

Insurance: Yes No I Dont know

Number of drivers: 1 2 3

Php code

Product Cost Calculator .number { font-weight: bold;} <?php // Script 4.2 - handle_calc.php /* This script takes values from calculator.html and performs total cost and monthly payment calculations. */

// Address error handling, if you want.

// Get the values from the $_POST array:
$days = $_POST[‘days’];
$deposit = $_POST[‘deposit’];
$endMil = $_POST[‘endMil’];
$starMil = $_POST[‘starMil’];
$response = $_POST[‘response’];
$drivers = $_POST[‘drivers’];

// Calculate the total:
$total = 30 * $days;
$total = $total + $shipping;
$total = $total - $discount;

// Determine the tax rate:
$taxrate = $tax/100;
$taxrate = $taxrate + 1;

// Factor in the tax rate:
$total = $total * $taxrate;

// Calculate the monthly payments:
$monthly = $total / $payments;

// Print out the results:
print “

You have selected to purchase:

<span class=“number”>$quantity widget(s) at

$<span class=“number”>$price price each plus a

$<span class=“number”>$shipping shipping cost and a

<span class=“number”>$tax percent tax rate.

After your $<span class=“number”>$discount discount, the total cost is
$<span class=“number”>$total.

Divided over <span class=“number”>$payments monthly payments, that would be $<span class=“number”>$monthly each.
”;

?>

any help or guidance would be greatly appreciated… Ive been working on tihs all weekend. and i just cant seem to get it right… Im Dyslexic so that kinda make it harder for me to get it to stick… but i will figure it out soon. i know once i do everything else will be easy to grasp

Thank you

First of all, you can use print with commas to separate parts that you want to print, e.g:

[php]print "hello ", “world”;[/php]

You can also use single quotations marks (’’) around strings - this avoids you having to escape every speech mark from your HTML code (note that this will not evaluate variables inside of the string, therefore we can combine both the above method of using print and single quotations with your form):

[php]<?php

print '<div>You have selected to purchase:<br />
<span class="number">', $quantity,
'</span> widget(s) at <br />',
'<span class="number">', $price, '</span> price each plus a <br />

', $shipping, ’ shipping cost and a

', $tax, ’ percent tax rate.

After your ', $discount, ’ discount, the total cost is
', $total, '.

Divided over ', $payments, ’ monthly payments, that would be ‘, $monthly, ’ each.

’;[/php]

There were a few extra dollar signs (not needed as you were not referencing a variable or defining one) that I removed. The above is just an example of a method I find easy to use - whether you use it is up to you.

What else with the script does not work?

Also, please let me know if you would like further explanation of anything in my post.

It appears I put print instead of echo.

Print does not work with commas whereas echo does! Sorry for the mistake!

[php]echo "epic ", “fail”;[/php]

Product Cost Calculator .number { font-weight: bold;} <?php // Script 4.2 - handle_calc.php /* This script takes values from calculator.html and performs total cost and monthly payment calculations. */

// Address error handling, if you want.

// Get the values from the $_POST array:
$days = $_POST[‘days’];
$deposit = $_POST[‘deposit’];
$endMil = $_POST[‘endMil’];
$starMil = $_POST[‘starMil’];
$response = $_POST[‘response’];
$drivers = $_POST[‘drivers’];

// Calculate the total:
$chargedays = $days * 30;
$totalmiles = $endMil - $starMil;
$chargemiles = $totalmiles - 100 * .35;
$totalcharges = $chargedays + $chargemiles;
//$totalamount = $insurance /.10 + $totalcharges;

// Print out the results:

print "

Charges for days: $chargedays

Total Miles: $totalmiles

Charge for Milage: $chargemiles

Total overall charges: $totalcharges

"

?>

Thanks ya’ll i got everything so far. i was mixing up alot of my code with old files… so i redid it again…

one last think i cant figure out if im suppose to do a If /else for these caluclation and how to write it.

If the customer selects insurance, the premium is 10% of the entire rental, including the mileage and driver charges. There is a driver charge of $5 per day for each driver – the first driver is free.

I had this before but i doubt this is correct.

// Validate the insurance if ($_POST['repsonse'] == 'Yes') { print '

True

'; } elseif ($_POST['repsonse'] == 'No') { print '<>False'; } elseif ($_POST['repsonse'] == 'I Dont know') { print '

False

';
Sponsor our Newsletter | Privacy Policy | Terms of Service