PHP Form echo set of numbers based on input
Posted: Mon Sep 22, 2008 2:25 pm
I have a form that outputs two different numbers "quotes" based on the person's age and sex. I am able to program it so that it pulls the right quote for the age, but how do I specify between age and sex? For example: if a person is between the age of 18-24 and is female her "quote" is 44.65, and if a person is between the age of 18-24 and is male his "quote" is 31.44.
Part of form that users input:
<select name="sex" id="sex">
<option value="female">female</option>
<option value="male">male</option>
My PHP Code
<?php
//page display after form submission
echo "<p><CENTER>Thank you, <b>$_POST[name]</b>, for requesting a quote.<br>
Your are eligable for heatlh insurance rates as low as:</p>";
if (($_POST['age'] >= 18) && ($_POST['age'] <= 25))
$quote=31.44;
elseif (($_POST['age'] >= 26) && ($_POST['age'] <= 30))
$quote=35.91;
elseif (($_POST['age'] >= 31) && ($_POST['age'] <= 35))
$quote=40.78;
elseif (($_POST['age'] >= 36) && ($_POST['age'] <= 40))
$quote=51.33;
elseif (($_POST['age'] >= 41) && ($_POST['age'] <= 45))
$quote=65.95;
elseif (($_POST['age'] >= 46) && ($_POST['age'] <= 50))
$quote=87.87;
elseif (($_POST['age'] >= 51) && ($_POST['age'] <= 60))
$quote=117.50;
elseif (($_POST['age'] >= 61) && ($_POST['age'] <= 64))
$quote=184.07;
//add children
$quote+=($_POST['children']*30.04);
echo "$".$quote."/month</p>
<p>CALL NOW: 1-877-278-3771<br>
TO START YOUR HEALTH INSURANCE COVERAGE!</p>";
//start building the mail string
$msg = "Name: $_POST[name]\n";
$msg .= "Age: $_POST[age]\n";
$msg .= "Sex: $_POST[sex]\n";
$msg .= "Children: $_POST[children]\n";
$msg .= "E-Mail: $_POST[email]\n";
$msg .= "Message: $_POST[message]\n";
//set up the mail to company
$recipient = "info@company.com";
$subject = "Health Insurance Quote";
$mailheaders = "From: 2 Step Health <info@company.com> \n";
//send the mail to company
mail($recipient, $subject, $msg, $mailheaders);
?>
Part of form that users input:
<select name="sex" id="sex">
<option value="female">female</option>
<option value="male">male</option>
My PHP Code
<?php
//page display after form submission
echo "<p><CENTER>Thank you, <b>$_POST[name]</b>, for requesting a quote.<br>
Your are eligable for heatlh insurance rates as low as:</p>";
if (($_POST['age'] >= 18) && ($_POST['age'] <= 25))
$quote=31.44;
elseif (($_POST['age'] >= 26) && ($_POST['age'] <= 30))
$quote=35.91;
elseif (($_POST['age'] >= 31) && ($_POST['age'] <= 35))
$quote=40.78;
elseif (($_POST['age'] >= 36) && ($_POST['age'] <= 40))
$quote=51.33;
elseif (($_POST['age'] >= 41) && ($_POST['age'] <= 45))
$quote=65.95;
elseif (($_POST['age'] >= 46) && ($_POST['age'] <= 50))
$quote=87.87;
elseif (($_POST['age'] >= 51) && ($_POST['age'] <= 60))
$quote=117.50;
elseif (($_POST['age'] >= 61) && ($_POST['age'] <= 64))
$quote=184.07;
//add children
$quote+=($_POST['children']*30.04);
echo "$".$quote."/month</p>
<p>CALL NOW: 1-877-278-3771<br>
TO START YOUR HEALTH INSURANCE COVERAGE!</p>";
//start building the mail string
$msg = "Name: $_POST[name]\n";
$msg .= "Age: $_POST[age]\n";
$msg .= "Sex: $_POST[sex]\n";
$msg .= "Children: $_POST[children]\n";
$msg .= "E-Mail: $_POST[email]\n";
$msg .= "Message: $_POST[message]\n";
//set up the mail to company
$recipient = "info@company.com";
$subject = "Health Insurance Quote";
$mailheaders = "From: 2 Step Health <info@company.com> \n";
//send the mail to company
mail($recipient, $subject, $msg, $mailheaders);
?>