Right. I think I’ve messed this project up then, ha!
So what I’ve done in my PHP wisdom is to have each question as an include, and when the user submits the form (along with the answer & i’m using $_POST) the next line looks at the submit variable and answer and then displays that include…
The answers are stored in a session but i think because im using the same form, it over writes it.
I’ll show you the code but don’t laugh or atleast type laughter, ha…
<?php session_start(); ?>
<?php include("includes/a_config.php");?>
<!DOCTYPE html>
<html>
<head>
<?php $CURRENT_PAGE = "Contact"; ?>
<?php include("includes/head-tag-contents.php");?>
</head>
<body>
<?php
//create sessions - my intention here was to collect their answers
$_SESSION['postcode'] = $_POST['postcode'];
$_SESSION['type_of_fuel'] = $_POST['type_of_fuel'];
$_SESSION['type_of_boiler'] = $_POST['type_of_boiler'];
$_SESSION['boiler_location'] = $_POST['boiler_location'];
$_SESSION['different_location'] = $_POST['different_location'];
$_SESSION['new_boiler_location'] = $_POST['new_boiler_location'];
$_SESSION['property_description'] = $_POST['property_description'];
$_SESSION['no_of_bedrooms'] = $_POST['no_of_bedrooms'];
$_SESSION['no_of_radiators'] = $_POST['no_of_radiators'];
$_SESSION['no_of_baths'] = $_POST['no_of_baths'];
$_SESSION['no_of_showers'] = $_POST['no_of_showers'];
$_SESSION['electric_shower'] = $_POST['electric_shower'];
$_SESSION['flue_location'] = $_POST['flue_location'];
$_SESSION['angle_flue_location'] = $_POST['angle_flue_location'];
$_SESSION['close_to_ground'] = $_POST['angle_flue_location'];
$_SESSION['close_to_property'] = $_POST['close_to_property'];
$_SESSION['close_to_structure'] = $_POST['close_to_structure'];
$_SESSION['30cm_close'] = $_POST['30cm_close'];
$_SESSION['convert_to_combi'] = $_POST['convert_to_combi'];
;?>
<?php include("includes/design-top.php");?>
<div class="container" id="main-content">
<h1 class="text-center">Help us to provide the best quote for you</h1>
<div id="quote_container" class="d-flex justify-content-center text-center">
<div style="position: fixed;top:0;left:0;background: white;text-align: left;padding: 1.5em;display:none;">
<?php
echo '<ol>';
echo '<li>What is their postcode <b>' .$_SESSION['postcode'].'</b></li>';
echo '<li>What kind of fuel does your boiler use? <b>' .$_SESSION['type_of_fuel'].'</b></li>';
echo '<li>What type of boiler do you currently have? <b>' .$_SESSION['type_of_boiler'].'</b></li>';
echo '<li>Where is your boiler currently boiler? <b>' .$_SESSION['boiler_location'].'</b></li>';
echo '<li>Do you want the boiler in a different location? <b>' .$_SESSION['different_location'].'</b></li>';
echo '<li>Which best describes your property? <b>' .$_SESSION['property_description'].'</b></li>';
echo '<li>A Visit is needed to be arranged</li>';
echo '<li>How many bedrooms do you have? <b>' .$_SESSION['no_of_bedrooms'].'</b></li>';
echo '<li>How many radiators? <b>' .$_SESSION['no_of_radiators'].'</b></li>';
echo '<li>How many bathtubs do you have, or plan to have? <b>' .$_SESSION['no_of_baths'].'</b></li>';
echo '<li>How many separate showers do you have, or plan to have in future? <b>' .$_SESSION['no_of_showers'].'</b></li>';
echo '<li>Where does your flue come out? <b>' .$_SESSION['flue_location'].'</b></li>';
echo '<li>Is your flue on a sloped roof or flat roof? <b>' .$_SESSION['angle_flue_location'].'</b></li>';
echo '<li>Where on the roof is it positioned? <b>' .$_SESSION['roof_position'].'</b></li>';
echo '<li>Is it square or round? <b>' .$_SESSION['flue_shape'].'</b></li>';
echo '<li>How close to the ground is your flue? <b>' .$_SESSION['close_to_ground'].'</b></li>';
echo '<li>How close to another property is your flue? <b>' .$_SESSION['close_to_property'].'</b></li>';
echo '<li>Is the flue under a carport balcony or other structure? <b>' .$_SESSION['close_to_structure'].'</b></li>';
echo '<li>Is the flue 30cm or more from a door or window? <b>' .$_SESSION['30cm_close'].'</b></li>';
echo '<li>Do you want to convert to a combi boiler?<b>' .$_SESSION['convert_to_combi'].'</b></li>';
echo '</ol>';
;?>
</div>
<form action="#quote_container" method="post">
<!-- STEP 1 - Would the Customer like to buy online or arrange a visit -->
<?php if(empty($_POST)){ ?>
<p>Would you like to <a href="">buy online</a> or arrange a <a href="">home visit</a>?</p>
<div class="form-group">
<!-- <button type="subit" class="btn btn-primary" name="online_quote" value="continue_online">Buy online</button> -->
<button type="submit" class="btn btn-primary" name="online_quote" value="continue_home">Start Quote</button>
</div>
<!-- Question 1 Enter Post Code -->
<?php }elseif ($_POST['online_quote'] === 'continue_home'){ ?>
<?php include("q1.php"); ?>
<?};?>
<!-- Question 2 What fuel does your boiler use -->
<?php if ( ($_POST['online_quote'] === 'continue_home_1') && (isset($_POST['postcode']))){ ?>
<?php include("q2.php"); ?>
<?};?>
<!-- Question 3 What type of boiler do you currently have -->
<?php if ($_POST['online_quote'] === 'continue_home_2'){ ?>
<?php include("q3.php"); ?>
<?};?>
<!-- Question 4 Where is your currently fitted? -->
<!-- This will only appear if user selects 'combi' -->
<?php if ( (($_POST['online_quote'] === 'continue_home_3') && ($_POST['type_of_boiler'] == 'Combi')) ||
(($_POST['online_quote'] === 'continue_home_21') && ($_POST['How close to the ground is your flue
_to_combi'] == 'No, to converting to Combi Boiler'))){ ?>
<?php include("q4.php"); ?>
<?};?>
<!-- Question 21 Do you want to convert to a combi boiler -->
<!-- This will only appear if user selects 'system' -->
<?php if ( ($_POST['online_quote'] === 'continue_home_3') && ($_POST['type_of_boiler'] == 'System')){ ?>
<?php include("q21.php"); ?>
<?};?>
<!-- Question 21 Do you want to convert to a combi boiler -->
<!-- This will only appear if user selects 'Heat Only' -->
<?php if ( ($_POST['online_quote'] === 'continue_home_3') && ($_POST['type_of_boiler'] == 'Heat Only')){ ?>
<?php include("q21.php"); ?>
<?};?>
<!-- Question 21 Do you want to convert to a combi boiler -->
<!-- This will only appear if user selects 'Back Boiler' -->
<?php if (( ($_POST['online_quote'] === 'continue_home_3') && ($_POST['type_of_boiler'] == 'Back Boiler'))||
(($_POST['online_quote'] === 'continue_home_5')&& ($_POST['different_location'] == 'yes, a different location'))||
(($_POST['online_quote'] === 'continue_home_21')&& ($_POST['convert_to_combi'] == 'Yes, How close to the ground is your flue
to Combi Boiler'))){ ?>
<?php include("q7.php"); ?>
<?};?>
<!-- Question 5 Do you want your boiler in a different place? -->
<?php if ($_POST['online_quote'] === 'continue_home_4'){ ?>
<?php include("q5.php"); ?>
<?};?>
<!-- Question 6 Which best describes your property -->
<!-- Get here by clicking 'NO' on question 5 -->
<?php if (($_POST['online_quote'] === 'continue_home_5')&& ($_POST['different_location'] == 'no, the same location')){ ?>
<?php include("q6.php"); ?>
<?};?>
<!-- Question 8 How Many Bedrooms do you have? -->
<?php if($_POST['online_quote'] === 'continue_home_6'){ ?>
<?php include("q8.php"); ?>
<?};?>
<!-- Question 9 How Many Radiators do you have? -->
<?php if($_POST['online_quote'] === 'continue_home_8'){ ?>
<?php include("q9.php"); ?>
<?};?>
<!-- Question 10 How Many bathtubs do you have, or plan to have in the future? -->
<?php if($_POST['online_quote'] === 'continue_home_9'){ ?>
<?php include("q10.php"); ?>
<?};?>
<!-- Question 11 How Many showers do you have, or plan to have in the future? -->
<?php if($_POST['online_quote'] === 'continue_home_10'){ ?>
<?php include("q11.php"); ?>
<?};?>
<!-- Question 12 Where does your flue come out? -->
<?php if($_POST['online_quote'] === 'continue_home_11'){ ?>
<?php include("q12.php"); ?>
<?};?>
<!-- Question 13 Is your Flue on a sloped roof or flat roof?? -->
<?php if(($_POST['online_quote'] === 'continue_home_13') && ($_POST['flue_location']== 'from the roof')){ ?>
<?php include("q13.php"); ?>
<?};?>
<!-- Question 13 Is your Flue on a sloped roof or flat roof?? -->
<?php if(($_POST['online_quote'] === 'continue_home_14') && ($_POST['angle_flue_location']== 'sloped')){ ?>
<?php include("q14.php"); ?>
<?};?>
<!-- Question 16 Is it square or round? -->
<!-- You get here by clicking 'Wall' on Q5 -->
<?php if(($_POST['online_quote'] === 'continue_home_13') && ($_POST['flue_location']== 'from the wall')){ ?>
<?php include("q16.php"); ?>
<?};?>
<!-- Question 15 PROVIDE A QUOTE -->
<?php if(($_POST['online_quote'] === 'continue_home_14') && ($_POST['roof_position']== 'roof position highest two thirds')
|| ($_POST['online_quote'] === 'continue_home_14') && ($_POST['roof_position']== 'roof position lowest third')
|| ($_POST['online_quote'] === 'continue_home_14') && ($_POST['angle_flue_location']== 'flat')
|| ($_POST['online_quote'] === 'continue_home_20')
){ ?>
<?php include("q15.php"); ?>
<?};?>
<!-- Question 17 How close to the ground is your flue -->
<!-- You get here by clicking 'Wall' on Q5 -->
<?php if($_POST['online_quote'] === 'continue_home_16'){ ?>
<?php include("q17.php"); ?>
<?};?>
<!-- Question 18 How close to another property is your flue? -->
<?php if($_POST['online_quote'] === 'continue_home_17'){ ?>
<?php include("q18.php"); ?>
<?};?>
<!-- Question 19 Is the flue under a carport, balcony or other structure? -->
<?php if($_POST['online_quote'] === 'continue_home_18'){ ?>
<?php include("q19.php"); ?>
<?};?>
<!-- Question 20 Is the flue 30cm or more from a door or window? -->
<?php if($_POST['online_quote'] === 'continue_home_19'){ ?>
<?php include("q20.php"); ?>
<?};?>
</form>
</div>
</div>
<?php include("includes/footer.php");?>
</body>
</html>
It’s not a school project, i wanted to help a buddy out with something and attempting to help…ha