I need a PHP function and calculation for the following- web hosting: $3, $6 or $12 monthly plus $5 each month for each extra ordered (e.g. more space, bandwidth, etc... all the extras are charged at a flat $5 each per month). The customer selects either the 3, 6 or 12 dollar plan and also selects the extras that they want. The code needs to calculate their monthly charge, plus add $5 for each extra that they chose based on their plan. What would be the best way to code this? Thanks gkz
there are two options Either you can use javascript or PHP javascript is not good as all code is visible to client so better use php Regards Alex
Yes it needs to be in PHP. So far I have this but need to define the arrays somehow so the $5 for each extra is added properly, plus the plan cost. // Calculate extras if (array_key_exists('extras', $_POST)) { $extras_array = $_POST['extras']; foreach ($extras_array as $extras) $total_extras = $extras += 5; } // Calculate fee if (array_key_exists('plan', $_POST)) { $plan['0'] = '3'; $plan['1'] = '6'; $plan['2'] = '12'; foreach ($plan_array as $plan) $fee = $total_extras + $plan; echo "<p>Monthly subscription fee: $$fee</p>"; } Am still learning so have probably got things mixed up. Thanks gkz
I have a done a script that shows how it works with AJAX/PHP. PM me if you want to see because i don't have permission to submit links.
Any help with this PHP coding would be much appreciated. I need to somehow add the price for each 'extra' that is selected and add it to the cost of the monthly plan. Thanks gkz