Hi guys, I need help a client of mine would like a call calculate that generates average savings depedning on the data input into the form.
The following Code is For the First Page which contains the form.
<?php function callcalc_form() {
$form = array();
$text = '<p><img src="/files/landlinetomobile/images/bigcalculator_0.jpg" alt="Calculator" title="calculator" align="right" hspace="10px" vspace="10px" width="250" height="235" />Centralcom are dedicated to saving companies however large or small money on their calls to mobile numbers.<br/><br/></p>
<p>Below can be found our call calculator which you can see the MINIMUM Centralcom could save your company on a monthly and annual basis.<br/><br/></p>
<p>Simply enter the amount of minutes and costs you are being presently being charged and hit ‘calculate now’ to see the results.<br/><br/></p>
<p>This information is readily obtained from your fixed line bills – if you have difficulties in obtaining this or understanding this from your current bills please contact us and our dedicated staff can assist you in attaining this information as well as offer you further information with no obligations.<br/><br/></p>
<p>Please note that our calculator shows only the Minimum savings that can be achieved by choosing to have Centralcom help you in your call cost reductions.<br/><br/></p>
<p><a href="/content/contact-us">Contact us</a> to see how much more we might be able to save too.</p>';
$form['text'] = array(
'#type' => 'item',
'#value' => $text,
);
$form['minutes'] = array(
'#type' => 'textfield',
'#title' => t('Monthly Minutes'),
'#decription' => t('Monthly minutes used calling mobiles in minutes'),
'#size' => 10,
);
$form['spend'] = array(
'#type' => 'textfield',
'#title' => t('Monthly Spend'),
'#decription' => t('Monthly spend on calls to mobiles in pounds(£)'),
'#size' => 10,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Calculate'),
);
return $form;
}
function callcalc_form_validate($form_id, $form_values) {
if (empty($form_values['minutes']) || !is_numeric($form_values['minutes'])) {
form_set_error('minutes', t('Please enter a numerical value'));
}
if (empty($form_values['spend']) || !is_numeric($form_values['spend'])) {
form_set_error('spend', t('Please enter a numerical value'));
}
}
function callcalc_form_submit($form_id, $form_values) {
$minutes = $form_values['minutes'];
$spend = $form_values['spend'];
//echo $minutes;
//echo $spend;
//First Total - Price per minute
$ppm = $spend / $minutes;
//echo $ppm;
//Second Total - minus 0.05 from ppm
$minus = 0.05;
$second_total = $ppm - $minus;
//echo $second_total;
//Third Total - Monthly saving - second total * total minutes
$third_total = $second_total * $minutes;
if ($third_total < 0) {
$third_total = 0;
}
//echo $third_total;
//Fourth total - Annual saving - third total * 12
$fourth_total = $third_total * 12;
//echo $fourth_total;
}
?>
The action for the form is ( <form action="callcalc2.php?'third=$third_total&fourth=$fourth_total" accept-charset="UTF-8" method="post" id="callcalc-form">)
This then takes me to callcalc2.php on this page the only php i have is;
<?php
$third_total = $_POST['third'];
?>
Then
<?php echo $third_total; ?>
which dosent display the calculated value, as you can tell I dont know a huge amount about PHP any help would be hugly welcome
you can see the example on http://www.mking-designs.com/test/callcalc.php