I can tell PHP is going to be lots of fun however, there are the pains of beginning something from scratch. I have made several errors up to now but just cannot see what the problem is here.
You can see the form at http://php.cedarsprings.cc/orderform.html
I want to apply a discount to the pro price at two levels. I think I have written the php code correctly but the discount isn't applied.
Thanks for any help...
<?php
// create short variable names
$pro = $POST['pro'];
$comp = $POST['comp'];
$personal = $POST['personal'];
$diy = $POST['diy'];
$host = $POST['host'];
$qna = $POST['qna'];
$facts = $POST['facts'];
$calc = $POST['calc'];
$news = $POST['news'];
$setupcomp = $POST['setupcomp'];
$setuppersonal = $POST['setuppersonal'];
$setuphost = $POST['setuphost'];
echo '<p>Your order is as follows: </p>';
$totalqty = 0;
$totalqty = $pro + $comp + $personal + $diy + $host + $qna + $facts + $calc + $news;
echo 'Items Ordered: '.$totalqty.'<br />';
$totalamount = 0.00;
define('PROPRICE', 300.00);
define('COMPPRICE', 200.00);
define('PERSONALPRICE', 100.00);
define('DIYPRICE', 1000.00);
define('HOSTPRICE', 400.00);
define('QNAPRICE', 100.00);
define('FACTSPRICE', 100.00);
define('CALCPRICE', 100.00);
define('NEWSPRICE', 100.00);
define('SETUPCOMPPRICE', 50.00);
define('SETUPPERSONALPRICE', 100.00);
define('SETUPHOSTPRICE', 200.00);
$totalamount = $pro PROPRICE
+ $comp COMPPRICE
+ $personal PERSONALPRICE
+ $diy DIYPRICE
+ $host HOSTPRICE
+ $qna QNAPRICE
+ $facts FACTSPRICE
+ $calc CALCPRICE
+ $news NEWSPRICE;
+ $setupcomp SETUPCOMPPRICE;
+ $setuppersonal SETUPPERSONALPRICE;
+ $setuphost SETUPHOSTPRICE;
echo 'Subtotal: $'.number_format($totalamount,2).'<br />';
if( $pro < 2 )
$discount = 0;
elseif( $pro >= 2 && $pro <= 5 )
$discount = 10;
elseif( $pro >= 5 && $pro <= 9 )
$discount = 20;
$taxrate = 0.15; // local salestax is 15%
$totalamount = $totalamount * (1 + $taxrate);
echo 'Total including tax: $'.number_format ($totalamount,2).'<br />';
if( $totalqty == 0 )
{
echo '<font color=red>';
echo 'You did not order anything! <br />';
echo '</font>';
}
else
{
if ($pro> 0 )
echo $pro.' Professional Plan<br />';
if ($comp> 0 )
echo $comp.' Comprehensive Plan<br />';
if ($personal> 0 )
echo $personal.' Personal Plan<br />';
if ($diy> 0 )
echo $diy.' DIY Plan<br />';
if ($host> 0 )
echo $host.' Hosting Only Plan<br />';
if ($qna> 0 )
echo $qna.' Quick Q & A ToolKit<br />';
if ($facts> 0 )
echo $facts.' Qucik Facts ToolKit<br />';
if ($calc> 0 )
echo $calc.' Calculators ToolKit<br />';
if ($news> 0 )
echo $news.' Quarterly Newsletters ToolKit<br />';
}
echo '<p>Order processed at ';
echo date('H:i, jS F');
echo '</p>';
?>