PHP Form echo set of numbers based on input
Posted: Wed Sep 10, 2008 10:29 am
I have a simple php mail form that echos user input after submission and also mails input information to specified email address. One of the fields is age. Is there a way to echo a set of numbers (insurance quote rates)based on the user's input of age? For example, if user inputs an age range from 18-24, $150/month would display on page after submission, if the user inputs an age range from 25-31, $175/month would display on the page after submission.
This is my form page code:
<HTML>
<HEAD>
<TITLE>E-Mail Form</TITLE></HEAD>
<BODY>
<FORM action="sendmail.php" method="POST">
<p><strong>Name:</strong>
<INPUT type="text" size="25" name="name"></p>
<p><strong>Age:</strong>
<INPUT type="text" size="3" name="age"><b>
<select name="sex" id="sex">
<option value="female">female</option>
<option value="male">male</option>
</select>
</b></p>
<p><strong>Children:</strong>
<INPUT type="text" size="3" name="children">
</p>
<p><strong>E-Mail Address:</strong>
<INPUT type="text" size="25" name="email"></p>
<p><strong>Message:</strong><br>
<textarea name="message" cols=30 rows=5></textarea></p>
<p><INPUT type="submit" value="send"></p>
</FORM>
</BODY>
</HTML>
This is my php processing code:
<html>
<head>
<title>Health Insurance Rates</title>
</head>
<body>
<?php
//page display after form submission
echo "<p>Thank you, <b>$_POST[name]</b>, for your message!</p>";
echo "<p>Your e-mail address is: <b>$_POST[email]</b>.</p>";
echo "<p>Your message was:<br>";
echo "$_POST[message] </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
$recipient = "info@ringartdesign.com";
$subject = "Health Insurance Quote";
$mailheaders = "From: 2 Step Health <info@2stephealth.com> \n";
$mailheaders .= "Reply-To: $_POST[email]";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
?>
</body>
</html>
This is my form page code:
<HTML>
<HEAD>
<TITLE>E-Mail Form</TITLE></HEAD>
<BODY>
<FORM action="sendmail.php" method="POST">
<p><strong>Name:</strong>
<INPUT type="text" size="25" name="name"></p>
<p><strong>Age:</strong>
<INPUT type="text" size="3" name="age"><b>
<select name="sex" id="sex">
<option value="female">female</option>
<option value="male">male</option>
</select>
</b></p>
<p><strong>Children:</strong>
<INPUT type="text" size="3" name="children">
</p>
<p><strong>E-Mail Address:</strong>
<INPUT type="text" size="25" name="email"></p>
<p><strong>Message:</strong><br>
<textarea name="message" cols=30 rows=5></textarea></p>
<p><INPUT type="submit" value="send"></p>
</FORM>
</BODY>
</HTML>
This is my php processing code:
<html>
<head>
<title>Health Insurance Rates</title>
</head>
<body>
<?php
//page display after form submission
echo "<p>Thank you, <b>$_POST[name]</b>, for your message!</p>";
echo "<p>Your e-mail address is: <b>$_POST[email]</b>.</p>";
echo "<p>Your message was:<br>";
echo "$_POST[message] </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
$recipient = "info@ringartdesign.com";
$subject = "Health Insurance Quote";
$mailheaders = "From: 2 Step Health <info@2stephealth.com> \n";
$mailheaders .= "Reply-To: $_POST[email]";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
?>
</body>
</html>