phazlee
12-18-2008, 05:00 PM
Hi,
am doing a simple survey script. Manage to piece it together from different codes. Missing the ending part.
What I want to do is get the result part to show on a new page. How can I acheive this? The things I want to appear on a new page are in blue.
Any help is appreciated thanks.
The code :
<?php
if(isset($_POST[submit]))
{
if($_POST['que1']=="")
$strError .= "<li>Please select an answer for question 1</li>";
if($_POST['que2']=="")
$strError .= "<li>Please select an answer for question 2</li>";
if($_POST['que3']=="")
$strError .= "<li>Please select an answer for question 3</li>";
if($_POST['que4']=="")
$strError .= "<li>Please select an answer for question 4</li>";
if($_POST['que5']=="")
$strError .= "<li>Please select an answer for question 5</li>";
if($_POST['que6']=="")
$strError .= "<li>Please select an answer for question 6</li>";
if($_POST['que7']=="")
$strError .= "<li>Please select an answer for question 7</li>";
if(empty($strError)){
$Total = $_POST[que1]+$_POST[que2]+$_POST[que3]+$_POST[que4]+$_POST[que5]+$_POST[que6]+$_POST[que7];
}
}
?>
<style type="text/css">
<!--
.style2 {
font-size: 24px;
font-weight: bold;
}
-->
</style>
<form action="" method="post">
<table width="650" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">1. Are you unable to maintain a balanced nutrition due to personal circumstances such as lack of time, laziness and lack of knowledge?</td>
</tr>
<tr>
<td width="63">Yes
<input type="radio" name="que1" value="1" <?php if($_POST[que1]==1){?> checked<?php } ?>></td>
<td width="95">Maybe
<input type="radio" name="que1" value="2" <?php if($_POST[que1]==2){?> checked<?php } ?>></td>
<td width="242">No
<input type="radio" name="que1" value="3" <?php if($_POST[que1]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">2. Are you eating too little fruits, vegetables and salads? </td>
</tr>
<tr>
<td>Yes <input type="radio" name="que2" value="1"<?php if($_POST[que2]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que2" value="2"<?php if($_POST[que2]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que2" value="3"<?php if($_POST[que2]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">3. Are you eating too much meat and too many fatty foods? </td>
</tr>
<tr>
<td>Yes <input type="radio" name="que3" value="1"<?php if($_POST[que3]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que3" value="2"<?php if($_POST[que3]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que3" value="3"<?php if($_POST[que3]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">4. Are you drinking too much alcohol, coffee and sweet drinks?<br>
(Alcohol does not only promote the excretion of vitamins and minerals, it also increases the need of them) </td>
</tr>
<tr>
<td>Yes <input type="radio" name="que4" value="1"<?php if($_POST[que4]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que4" value="2"<?php if($_POST[que4]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que4" value="3"<?php if($_POST[que4]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">5. Are you eating too many sweets and simple sugars instead of wholemeal products?<br>
(Refined and denaturalized foods such as cakes, white flour, white rice)</td>
</tr>
<tr>
<td>Yes <input type="radio" name="que5" value="1"<?php if($_POST[que5]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que5" value="2"<?php if($_POST[que5]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que5" value="3"<?php if($_POST[que5]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">6. Are you eating an imbalanced diet, too quickly and too late at night? </td>
</tr>
<tr>
<td>Yes <input type="radio" name="que6" value="1"<?php if($_POST[que6]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que6" value="2"<?php if($_POST[que6]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que6" value="3"<?php if($_POST[que6]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">7.Are you placing excessive demands on your digestive tracts and they can no longer fully digest your foods? </td>
</tr>
<tr>
<td>Yes <input type="radio" name="que7" value="1"<?php if($_POST[que7]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que7" value="2"<?php if($_POST[que7]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que7" value="3"<?php if($_POST[que7]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3" align="center"><?=$strError;?></td>
</tr>
<tr>
<td colspan="3" align="center"> </td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Submit"></td>
</tr>
<?php if(!empty($Total))
{ ?>
<tr>
<td colspan="3" align="center"><p> </p>
<p><span class="style2">Your score is
<?=$Total?>
out of 21</span></p>
<p>
<img src="images/bar.png" width="549" height="79" /><br>
</p>
<p>I recommend the following book and I hope it can improve your nutritional status.<br>
<em><b>“What Your Doctor Doesn’t Know about Nutritional Medicine May Be Killing You”</b></em> <br>
by Dr Ray Strand, M.D. </p>
<p><br>
<a href="what.htm" target="_blank"><img src="images/next1.gif" /></a> </p></td>
</tr><?php } ?>
<tr>
<td colspan="3" align="center"> </td>
</tr>
</table></form>
Sorry bout the earlier missing PHP quotes now can someone help? Thanks
am doing a simple survey script. Manage to piece it together from different codes. Missing the ending part.
What I want to do is get the result part to show on a new page. How can I acheive this? The things I want to appear on a new page are in blue.
Any help is appreciated thanks.
The code :
<?php
if(isset($_POST[submit]))
{
if($_POST['que1']=="")
$strError .= "<li>Please select an answer for question 1</li>";
if($_POST['que2']=="")
$strError .= "<li>Please select an answer for question 2</li>";
if($_POST['que3']=="")
$strError .= "<li>Please select an answer for question 3</li>";
if($_POST['que4']=="")
$strError .= "<li>Please select an answer for question 4</li>";
if($_POST['que5']=="")
$strError .= "<li>Please select an answer for question 5</li>";
if($_POST['que6']=="")
$strError .= "<li>Please select an answer for question 6</li>";
if($_POST['que7']=="")
$strError .= "<li>Please select an answer for question 7</li>";
if(empty($strError)){
$Total = $_POST[que1]+$_POST[que2]+$_POST[que3]+$_POST[que4]+$_POST[que5]+$_POST[que6]+$_POST[que7];
}
}
?>
<style type="text/css">
<!--
.style2 {
font-size: 24px;
font-weight: bold;
}
-->
</style>
<form action="" method="post">
<table width="650" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">1. Are you unable to maintain a balanced nutrition due to personal circumstances such as lack of time, laziness and lack of knowledge?</td>
</tr>
<tr>
<td width="63">Yes
<input type="radio" name="que1" value="1" <?php if($_POST[que1]==1){?> checked<?php } ?>></td>
<td width="95">Maybe
<input type="radio" name="que1" value="2" <?php if($_POST[que1]==2){?> checked<?php } ?>></td>
<td width="242">No
<input type="radio" name="que1" value="3" <?php if($_POST[que1]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">2. Are you eating too little fruits, vegetables and salads? </td>
</tr>
<tr>
<td>Yes <input type="radio" name="que2" value="1"<?php if($_POST[que2]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que2" value="2"<?php if($_POST[que2]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que2" value="3"<?php if($_POST[que2]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">3. Are you eating too much meat and too many fatty foods? </td>
</tr>
<tr>
<td>Yes <input type="radio" name="que3" value="1"<?php if($_POST[que3]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que3" value="2"<?php if($_POST[que3]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que3" value="3"<?php if($_POST[que3]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">4. Are you drinking too much alcohol, coffee and sweet drinks?<br>
(Alcohol does not only promote the excretion of vitamins and minerals, it also increases the need of them) </td>
</tr>
<tr>
<td>Yes <input type="radio" name="que4" value="1"<?php if($_POST[que4]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que4" value="2"<?php if($_POST[que4]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que4" value="3"<?php if($_POST[que4]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">5. Are you eating too many sweets and simple sugars instead of wholemeal products?<br>
(Refined and denaturalized foods such as cakes, white flour, white rice)</td>
</tr>
<tr>
<td>Yes <input type="radio" name="que5" value="1"<?php if($_POST[que5]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que5" value="2"<?php if($_POST[que5]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que5" value="3"<?php if($_POST[que5]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">6. Are you eating an imbalanced diet, too quickly and too late at night? </td>
</tr>
<tr>
<td>Yes <input type="radio" name="que6" value="1"<?php if($_POST[que6]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que6" value="2"<?php if($_POST[que6]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que6" value="3"<?php if($_POST[que6]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">7.Are you placing excessive demands on your digestive tracts and they can no longer fully digest your foods? </td>
</tr>
<tr>
<td>Yes <input type="radio" name="que7" value="1"<?php if($_POST[que7]==1){?> checked<?php } ?>></td>
<td>Maybe <input type="radio" name="que7" value="2"<?php if($_POST[que7]==2){?> checked<?php } ?>></td>
<td>No <input type="radio" name="que7" value="3"<?php if($_POST[que7]==3){?> checked<?php } ?>></td>
</tr>
<tr>
<td colspan="3" align="center"><?=$strError;?></td>
</tr>
<tr>
<td colspan="3" align="center"> </td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="submit" value="Submit"></td>
</tr>
<?php if(!empty($Total))
{ ?>
<tr>
<td colspan="3" align="center"><p> </p>
<p><span class="style2">Your score is
<?=$Total?>
out of 21</span></p>
<p>
<img src="images/bar.png" width="549" height="79" /><br>
</p>
<p>I recommend the following book and I hope it can improve your nutritional status.<br>
<em><b>“What Your Doctor Doesn’t Know about Nutritional Medicine May Be Killing You”</b></em> <br>
by Dr Ray Strand, M.D. </p>
<p><br>
<a href="what.htm" target="_blank"><img src="images/next1.gif" /></a> </p></td>
</tr><?php } ?>
<tr>
<td colspan="3" align="center"> </td>
</tr>
</table></form>
Sorry bout the earlier missing PHP quotes now can someone help? Thanks