I have searched google/php forms/etc for an answer but it seems to be each situation is diffrent and I'm not able to get it just right for me. What I am trying to do is: 1.User fills out a quiz. 2.Based off certain answers, certain responses show up. (working). I am now being asked to change it where instead of showing a final score and topics, it needs to redirect to a page dedicated to that - I have diabetes == true user is redirected to diabetic.php. Now - trick is, there are 'levels' - Diabetics > Heart Disease > Cancer > Nothing. Each has it's own question due to the scoring. I hope that helps.
I am not sure what code I need to post as I think I'll have to re-write it due to the passing of scores from the quiz page to the new page to show the score there. I've ommited the questions that I am not concerned about.
Code: Select all
<?php
$iteration = 0;
if ($_POST['fff_x']) {
/* Scoreing / point code */
$cat01score = $dietpoints + $hwpoints;
$cat02score = $expoints;
$cat03score = $labmedpoints;
$cat04score = $usepoints;
$score = $cat01score + $cat02score + $cat03score + $cat04score;
$iteration = 1;
/* This is the 'questions' results that need to re-direct */
if ($q06 != "c") {$cat05statement .= "Based off your answers, we feel you should check out the:
<br /><center><a href='http://www.foodfitnessfirst.com/DiabeticSpiral.php'><img src='images/Button_DiabeticSpiral.png' alt='Diabetic Spiral' border=0 /></a></center>";} /* should be sent to 'DiabeticSpiral.php' */
elseif ($q07 != "c") {$cat05statement .= "Based off your answers, we feel you should check out the:
<br /><center><a href='http://www.foodfitnessfirst.com/wellness/LowSodium/LSSpiral.php'><img src='images/Button_LowNASpiral.png' alt='Low Sodium Spiral' border=0 /></a></center>";}
elseif ($q09 != "c") {$cat05statement .= "Based off your answers, we feel you should check out the:
<br /><center><a href='http://www.foodfitnessfirst.com/RenalSpiral.php'><img src='images/Button_RenalSpiral.png' alt='Renal Spiral' border=0 /></a></center>";}
else {$cat05statement .= "Based off your answers, we feel you should check out the:
<br /><center><a href='http://www.foodfitnessfirst.com/spiral_well.php'><img src='images/Button_HealthySpiral.png' alt='Healthy Spiral' border=0 /></a></center>";}
}
?>
<?php
if ( $iteration == 1 ) { print <<<EOF
<html> <body>
$totalscore
<h4>Four Categories and the Factor for each area:</h4>
<table cellpadding="5" cellspacing="0" width="100%" style="border:solid black thin;">
<tr>
<td valign="bottom" align="left"><p style="color:green;"><strong>Category</strong></p></td>
<td valign="bottom" align="center"><p style="color:green;"><strong>Maximum<br />Score</strong></p></td>
<td valign="bottom" align="center"><p style="color:green;"><strong>Your<br />Score</strong></p></td>
</tr>
<tr>
<td colspan="3"><hr color="black" width="100%"></td>
</tr>
<tr>
<td valign="top" align="left"><p><strong>Diet/Height/Weight</strong></p></td>
<td valign="top" align="center"><p>30</p></td>
<td valign="top" align="center"><p>$cat01score</p></td>
</tr>
<tr>
<td colspan="3">$cat01statement</td>
</tr>
<tr>
<td colspan="3"><hr color="black" width="100%"></td>
</tr>
<tr>
<td valign="top" align="left"><p><strong>Exercise</strong></p></td>
<td valign="top" align="center"><p>15</p></td>
<td valign="top" align="center"><p>$cat02score</p></td>
</tr>
<tr>
<td colspan="3">$cat02statement</td>
</tr>
<tr>
<td colspan="3"><hr color="black" width="100%"></td>
</tr>
<tr>
<td valign="top" align="left"><p><strong>Disease/Labs/Meds</strong></p></td>
<td valign="top" align="center"><p>30</p></td>
<td valign="top" align="center"><p>$cat03score</p></td>
</tr>
<tr>
<td colspan="3">$cat03statement</td>
</tr>
<tr>
<td colspan="3"><hr color="black" width="100%"></td>
</tr>
<tr>
<td valign="top" align="left"><p><strong>Alcohol/Tobacco</strong></p></td>
<td valign="top" align="center"><p>25</p></td>
<td valign="top" align="center"><p>$cat04score</p></td>
</tr>
<tr>
<td colspan="3">$cat04statement</td>
</tr>
<tr>
<td colspan="3"><hr color="black" width="100%"></td>
</tr>
<tr>
<td valign="top" align="left" colspan="3"><p><strong>Related Food Spiral</strong></p></td>
</tr>
<tr>
<td colspan="3">$cat05statement</td>
</tr>
</table>
</div>
</div>
</body></html>
EOF; }
else { print <<<END
<html><body>
<h2>Favorable Fitness Factor</h2>
<form method="post">
/* These are the quesitons that should determine the redirect. */
<h3>Health Conditions</h3>
Do you have Diabetes?<br />
<input type="radio" name="q06" size=2 value="a" tabindex="38" />Yes, and my doctor feels it IS under control.<br />
<input type="radio" name="q06" size=2 value="b" />Yes, and my doctor feels it IS NOT under control.<br />
<input type="radio" name="q06" size=2 value="c" />No<br /><br />
Do you have Heart Disease (including High Blood Pressure or Stroke)?<br />
<input type="radio" name="q07" size=2 value="a" tabindex="39" />Yes, and my doctor feels it IS under control.<br />
<input type="radio" name="q07" size=2 value="b" />Yes, and my doctor feels it IS NOT under control.<br />
<input type="radio" name="q07" size=2 value="c" />No<br /><br />
Do you have Cancer?<br />
<input type="radio" name="q08" size=2 value="a" tabindex="40" />Yes, and my doctor feels it IS under control.<br />
<input type="radio" name="q08" size=2 value="b" />Yes, and my doctor feels it IS NOT under control.<br />
<input type="radio" name="q08" size=2 value="c" />No<br /><br />
Do you have Renal Disease?<br />
<input type="radio" name="q09" size=2 value="a" tabindex="41" />Yes, and my doctor feels it IS under control.<br />
<input type="radio" name="q09" size=2 value="b" />Yes, and my doctor feels it IS NOT under control.<br />
<input type="radio" name="q09" size=2 value="c" />No<br /><br />
Does your family have a history of Diabetes, Heart Disease, Stroke, High Blood Pressure, Cancer, or Kidney Disease?<br />
<input type="radio" name="q10" size=2 value="a" tabindex="42" />Yes<br />
<input type="radio" name="q10" size=2 value="b" />No<br /><br />
<div align="center">
<strong>After answering the questions, click on the button below to get your FFF score:</strong><br /><br />
<input type="image" src="/images/scorebutton.jpg" name="fff" value="Get My Score" size="228,56" border="0" tabindex="69" />
</div>
</form>
</body></html>
END; } ?>