I want to create a price quote page using Chronoforms, by calculating the values that are submitted in the form. I've got the email to work, and the thank you page displays, but the variables are not appearing correctly. What am I doing wrong?
I put the calculations in the Custom Code - Before Email(s):
Then I put this in the Show Thanks Message:
In both the email as well as the thank you page, the result shows nothing for the values.
Help...
I put the calculations in the Custom Code - Before Email(s):
<?php
// Get values from the form
$recipient = $_POST['email'];
$hours_needed = isset($_POST['hours_needed']) ? intval($_POST['hours_needed']) : 0;
$property_size = isset($_POST['property_size']) ? intval($_POST['property_size']) : 0;
$property_type = isset($_POST['property_type']) ? intval($_POST['property_type']) : 0;
$uniform_type = isset($_POST['uniform_type']) ? intval($_POST['uniform_type']) : 0;
$guards = isset($_POST['guards']) ? intval($_POST['guards']) : 0;
$guard_type = isset($_POST['guard_type']) ? intval($_POST['guard_type']) : 0;
$extras = isset($_POST['extras']) ? intval($_POST['extras']) : 0;
$name = isset($_POST['name']) ? intval($_POST['name']) : 0;
// Define some constants to be used later
define('unarmed', 11.0);
define('armed', 19.0);
define('casual_uniform', 200.0);
define('tactical_uniform', 280.0);
define('corporate_uniform', 200.0);
define('residential', 0.2);
define('commercial', 0.25);
define('corporate', 0.35);
define('government', 0.3);
define('event', 0.2);
define('guardscan', 600.0);
define('golfcart', 2000.0);
// Do our calculations
$hourly_rate_low = (((((($guard_type + ($guard_type * 0.08) + ($guard_type * 0.04) + ($guard_type * 0.01)) * $hours_needed) * 52) + ((($property_size * 0.01) / $guards) + (($uniform_type * 2) * $guards) + 3600 + 56 + $extras)) / 52) / $hours_needed);
$monthly_rate_low = (((($guard_type + ($guard_type * 0.08) + ($guard_type * 0.04) + ($guard_type * 0.01)) * $hours_needed) * 52) + ((($property_size * 0.01) / $guards) + (($uniform_type * 2) * $guards) + 3600 + 56 + $extras)) / 12;
$hourly_rate_high = $hourly_rate_low * 1.15;
$monthly_rate_high = $monthly_rate_low * 1.15;
$setup_fee_low = $monthly_rate_low * 0.1;
$setup_fee_high = $monthly_rate_high * 0.1;
?>
Then I put this in the Show Thanks Message:
<h2>Requested Quote</h2>
<p>Hi <?=$name;?>,</p>
<p>Thanks for requesting a quote. Here you go:</p>
<table style="padding:10px;">
<thead>
<tr>
<th>Description</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
<tr>
<td style="padding:10px;">Hourly rate</td>
<td style="padding:10px;">$<?=$hourly_rate_low;?> - $<?=$hourly_rate_high;?></td>
</tr>
<tr>
<td style="padding:10px;">One time setup fee</td>
<td style="padding:10px;">$<?=$setup_fee_low;?> - $<?=$setup_fee_high;?></td>
</tr>
<tr>
<td style="padding:10px;">Monthly charge</td>
<td style="padding:10px;">$<?=$monthly_rate_low;?> - $<?=$monthly_rate_high;?></td>
</tr>
</tbody>
</table>
In both the email as well as the thank you page, the result shows nothing for the values.
Help...