Ik heb een eenvoudig script en het script doet het niet. Ik gebruik een lokale server en andere scripts doen het prima. Het gaat om een HTML-formulier waarvan de waarden naar een PHP bestand worden geschreven. Wie weet wat er mis gaat?
HTML-formulier
PHP-bestand
HTML-formulier
HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>Product cost calculator</title>
</head>
<body>
Fill out this form to calculate the costs: <br />
<form action="handle_calc.php" method="post">
Price:<input type="text" name="price" size="5"><br />
Quantity:<input type="text" name="quantity" size="5"><br />
Discount:<input type="text" name="discount" size="5"><br />
Tax:<input type="text" name="tax" size="3"><br />
Shipping method:<select name="shipping">
<option value="5.00">Slow and steady</option>
<option value="8.95">Put a move on it</option>
<option value="19.36">I need it yesterday</option>
</select>
<br />
Number of payment to make: <input type="text" name="payments" size="3" />
<br />
<input type="submit" name="submit" value="calculate" />
</form>
<!--Calculator.html-->
</body>
</html>
PHP-bestand
PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title>Product Cost</title>
</head>
<body>
<?php//script hand_calc.php
/*this script takes value from calculator.html and
performs total cost and monthly payments calculations*/
ini_set('display_errors',1);
error_reporting(E_ALL&~E_NOTICE);
$price=$_POST['price'];
$quantity=$_POST['quantity'];
$discount=$_POST['discount'];
$tax=$_POST['tax'];
$shipping=$_POST['shipping'];
$payments=$_POST['payments'];
//calculate the total
$total=$price*$quantity;
$total=$total+$shipping;
$total=$total-$discount;
//Determine the taxrate
$taxrate=$tax/100;
$taxrate=$taxrate + 1;
//Factor in the taxrate
$total=$total*$taxrate;
//calculate the monthly payments
$monthly=$total/$payments;
//print out the results
print "you have selected to purchase: <br />
<b>$quantity</b>widgets at<br />
$<b>$price</b>price with a <br />
$<b>$shipping</b> shipping costs and a<br />
<b> $tax</b>percent tax rate<br />
After your $<b>$discount</b>discount the ,
total cost is
$<b>$total</b>.<br />
Divided over<b>$payments</b>montly payments,
that would be $<b>$monthly</b>each.";
?>
</body>
</html>
Laatst bewerkt door een moderator: