ringartdesign Posted October 23, 2008 Share Posted October 23, 2008 This may not be a php question or simply a html form question, but thought I'd try. I have a html form: https://2stephealth.com/get_quote.html That directs to a php page that calculates a quote based on their age, gender, etc. This works perfectly as is, however, if a person is 65 or older the form returns $0 on quote.php. How can I have the form return a brand new quote page (quote_seniors.php) if the person enters an age of 65 or older? Here is my php processing: <?php if (($_POST['age'] >= 18) && ($_POST['age'] <= 25) && ($_POST['sex'] =="male")) $quote=31.44; elseif (($_POST['age'] >= 18) && ($_POST['age'] <= 25) && ($_POST['sex'] =="female")) $quote=44.65; elseif (($_POST['age'] >= 26) && ($_POST['age'] <= 30) && ($_POST['sex'] =="male")) $quote=35.91; elseif (($_POST['age'] >= 26) && ($_POST['age'] <= 30) && ($_POST['sex'] =="female")) $quote=50.33; elseif (($_POST['age'] >= 31) && ($_POST['age'] <= 35) && ($_POST['sex'] =="male")) $quote=40.78; elseif (($_POST['age'] >= 31) && ($_POST['age'] <= 35) && ($_POST['sex'] =="female")) $quote=62.11; elseif (($_POST['age'] >= 36) && ($_POST['age'] <= 40) && ($_POST['sex'] =="male")) $quote=51.33; elseif (($_POST['age'] >= 36) && ($_POST['age'] <= 40) && ($_POST['sex'] =="female")) $quote=76.72; elseif (($_POST['age'] >= 41) && ($_POST['age'] <= 45) && ($_POST['sex'] =="male")) $quote=65.95; elseif (($_POST['age'] >= 41) && ($_POST['age'] <= 45) && ($_POST['sex'] =="female")) $quote=92.55; elseif (($_POST['age'] >= 46) && ($_POST['age'] <= 50) && ($_POST['sex'] =="male")) $quote=87.87; elseif (($_POST['age'] >= 46) && ($_POST['age'] <= 50) && ($_POST['sex'] =="female")) $quote=108.38; elseif (($_POST['age'] >= 51) && ($_POST['age'] <= 60) && ($_POST['sex'] =="male")) $quote=117.51; elseif (($_POST['age'] >= 51) && ($_POST['age'] <= 60) && ($_POST['sex'] =="female")) $quote=126.65; elseif (($_POST['age'] >= 61) && ($_POST['age'] <= 64) && ($_POST['sex'] =="male")) $quote=184.07; elseif (($_POST['age'] >= 61) && ($_POST['age'] <= 64) && ($_POST['sex'] =="female")) $quote=168.87; //add spouse if (($_POST['spouse_age'] >= 18) && ($_POST['spouse_age'] <= 25) && ($_POST['spouse_sex'] =="male")) $quote+=31.44; elseif (($_POST['spouse_age'] >= 18) && ($_POST['spouse_age'] <= 25) && ($_POST['spouse_sex'] =="female")) $quote+=44.65; elseif (($_POST['spouse_age'] >= 26) && ($_POST['spouse_age'] <= 30) && ($_POST['spouse_sex'] =="male")) $quote+=35.91; elseif (($_POST['spouse_age'] >= 26) && ($_POST['spouse_age'] <= 30) && ($_POST['spouse_sex'] =="female")) $quote+=50.33; elseif (($_POST['spouse_age'] >= 31) && ($_POST['spouse_age'] <= 35) && ($_POST['spouse_sex'] =="male")) $quote+=40.78; elseif (($_POST['spouse_age'] >= 31) && ($_POST['spouse_age'] <= 35) && ($_POST['spouse_sex'] =="female")) $quote+=62.11; elseif (($_POST['spouse_age'] >= 36) && ($_POST['spouse_age'] <= 40) && ($_POST['spouse_sex'] =="male")) $quote+=51.33; elseif (($_POST['spouse_age'] >= 36) && ($_POST['spouse_age'] <= 40) && ($_POST['spouse_sex'] =="female")) $quote+=76.72; elseif (($_POST['spouse_age'] >= 41) && ($_POST['spouse_age'] <= 45) && ($_POST['spouse_sex'] =="male")) $quote+=65.95; elseif (($_POST['spouse_age'] >= 41) && ($_POST['spouse_age'] <= 45) && ($_POST['spouse_sex'] =="female")) $quote+=92.55; elseif (($_POST['spouse_age'] >= 46) && ($_POST['spouse_age'] <= 50) && ($_POST['spouse_sex'] =="male")) $quote+=87.87; elseif (($_POST['spouse_age'] >= 46) && ($_POST['spouse_age'] <= 50) && ($_POST['spouse_sex'] =="female")) $quote+=108.38; elseif (($_POST['spouse_age'] >= 51) && ($_POST['spouse_age'] <= 60) && ($_POST['spouse_sex'] =="male")) $quote+=117.51; elseif (($_POST['spouse_age'] >= 51) && ($_POST['spouse_age'] <= 60) && ($_POST['spouse_sex'] =="female")) $quote+=126.65; elseif (($_POST['spouse_age'] >= 61) && ($_POST['spouse_age'] <= 64) && ($_POST['spouse_sex'] =="male")) $quote+=184.07; elseif (($_POST['spouse_age'] >= 61) && ($_POST['spouse_age'] <= 64) && ($_POST['spouse_sex'] =="female")) $quote+=168.87; ?> Link to comment https://forums.phpfreaks.com/topic/129812-direct-to-two-different-php-pages-based-on-form-entry/ Share on other sites More sharing options...
Alt_F4 Posted October 24, 2008 Share Posted October 24, 2008 I would probably use JS for this. create a function that is called when the form is submitted get the value of the age text field and then use an IF statement to set the action of the form NB: you will need to ad and id attribute to your inputs something like: function checkAge() { var age = document.getElementById('age').value; if(parseInt(age) >= 65) { document.quote.Action = "https://www.2stephealth.com/quote_seniors.php"; } } that should then submit to the other page if the age is 65+ Link to comment https://forums.phpfreaks.com/topic/129812-direct-to-two-different-php-pages-based-on-form-entry/#findComment-673300 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.