Help!
Posted: Mon Apr 07, 2008 5:36 am
Hi gang,
I'm on a deadline and I'm getting a little bit desperate now... It's a simple script but there's something funny going on... Here's the code:
__________________________
<?php
// this starts the session
session_start();
?>
<HTML>
<HEAD>
<link rel="stylesheet" type="Text/css" href="/stdtheme.css" />
</HEAD>
<?php
If (isset($page)) {
If ($page > 2) {
$to = "<email>";
$subject = "<subject>";
$txt = $_SESSION["answers"];
$header = "<from>";
mail($to,$subject,$txt,$headers);
echo "Thanks for participating. Your results have now been emailed.";
exit("Goodbye");
}
elseif ($page > 1) {
$questions = split(':', $_POST["QuestionID"]);
foreach ($questions as $id) {
$_SESSION["answers"] .= $id . ":" . $_POST['$id'] . "#";
}
}
writeQandA($page);
echo '<A HREF=<website>?page=' . ($page + 1) . '>';
echo "Next Page</A>";
}
else {
echo "Welcome to the Shout! Survey. <BR><BR>";
echo '<A HREF=<website>?page=1>';
echo 'Begin!<' . chr(47) . 'A>';
}
function writeQandA($page)
{
echo '<FORM Action=<website> Method=POST>';
If ($page = 1) {
echo 'Question 1: ';
echo 'This will be multiple choice, on page 1';
echo '<HR>';
echo '<TABLE>';
echo '<TR>';
echo '<TD>';
echo '1:';
echo '<input type=checkbox name=0 value=1>';
echo 'First answer to multiple';
echo '<' . chr(47) . 'TD>';
echo '<TD>';
echo '2:';
echo '<input type=checkbox name=0 value=2>';
echo 'Second Answer to multiple';
echo '<' . chr(47) . 'TD>';
}
If ($page = 2) {
echo 'Question 2: ';
echo 'This will be a single, on page 2';
echo '<HR>';
echo '<TABLE>';
echo '<TR>';
echo '<TD>';
echo '1:';
echo '<input type=radio name=1 value=1>';
echo 'This is the answer to the single q.';
echo '<' . chr(47) . 'TD>';
echo '<TD>';
echo '2:';
echo '<input type=radio name=1 value=2>';
echo 'This is the next answer to the single';
echo '<' . chr(47) . 'TD>';
}
echo '<' . chr(47) . 'TABLE>';
echo '<input type=hidden name=QuestionID value=1:3>';
echo '<' . chr(47) . 'FORM>';
}
?>
</HTML>
__________________________
Here's the problem; firstly that the page runs fine to give you the first intro, then on the next page to run the function writeQandA.
However, it shows each $page condition, so, it shows everything from the function even when I have echoed inside the function '$page' and it shows the right number from the url.
The other issue is the email it sends after the last one, it doesn't send the values from the question ids in the hidden input box, and the values from the input/checkboxes...
Thanks loads in advance to some help!!!
Jess.
I'm on a deadline and I'm getting a little bit desperate now... It's a simple script but there's something funny going on... Here's the code:
__________________________
<?php
// this starts the session
session_start();
?>
<HTML>
<HEAD>
<link rel="stylesheet" type="Text/css" href="/stdtheme.css" />
</HEAD>
<?php
If (isset($page)) {
If ($page > 2) {
$to = "<email>";
$subject = "<subject>";
$txt = $_SESSION["answers"];
$header = "<from>";
mail($to,$subject,$txt,$headers);
echo "Thanks for participating. Your results have now been emailed.";
exit("Goodbye");
}
elseif ($page > 1) {
$questions = split(':', $_POST["QuestionID"]);
foreach ($questions as $id) {
$_SESSION["answers"] .= $id . ":" . $_POST['$id'] . "#";
}
}
writeQandA($page);
echo '<A HREF=<website>?page=' . ($page + 1) . '>';
echo "Next Page</A>";
}
else {
echo "Welcome to the Shout! Survey. <BR><BR>";
echo '<A HREF=<website>?page=1>';
echo 'Begin!<' . chr(47) . 'A>';
}
function writeQandA($page)
{
echo '<FORM Action=<website> Method=POST>';
If ($page = 1) {
echo 'Question 1: ';
echo 'This will be multiple choice, on page 1';
echo '<HR>';
echo '<TABLE>';
echo '<TR>';
echo '<TD>';
echo '1:';
echo '<input type=checkbox name=0 value=1>';
echo 'First answer to multiple';
echo '<' . chr(47) . 'TD>';
echo '<TD>';
echo '2:';
echo '<input type=checkbox name=0 value=2>';
echo 'Second Answer to multiple';
echo '<' . chr(47) . 'TD>';
}
If ($page = 2) {
echo 'Question 2: ';
echo 'This will be a single, on page 2';
echo '<HR>';
echo '<TABLE>';
echo '<TR>';
echo '<TD>';
echo '1:';
echo '<input type=radio name=1 value=1>';
echo 'This is the answer to the single q.';
echo '<' . chr(47) . 'TD>';
echo '<TD>';
echo '2:';
echo '<input type=radio name=1 value=2>';
echo 'This is the next answer to the single';
echo '<' . chr(47) . 'TD>';
}
echo '<' . chr(47) . 'TABLE>';
echo '<input type=hidden name=QuestionID value=1:3>';
echo '<' . chr(47) . 'FORM>';
}
?>
</HTML>
__________________________
Here's the problem; firstly that the page runs fine to give you the first intro, then on the next page to run the function writeQandA.
However, it shows each $page condition, so, it shows everything from the function even when I have echoed inside the function '$page' and it shows the right number from the url.
The other issue is the email it sends after the last one, it doesn't send the values from the question ids in the hidden input box, and the values from the input/checkboxes...
Thanks loads in advance to some help!!!
Jess.