<?PHP

if (eregi("include_survey_confirm.php", $_SERVER['SCRIPT_NAME'])) {
    Header("Location: index.php"); die();
}

echo ("<form name='2008survey' method='post' action='survey_X.php' >"); //onSubmit=\"return confirm('Are you ready to submit your answers?');\"

echo ("<p><strong>Please review your answers before submitting.</strong><br /></p>");

$tripwire = 0;
foreach($_POST as $questionID => $answerID) {
    $questionID = ltrim($questionID,'qid');
	if (is_numeric($questionID)) {
	  $question = mysql_fetch_array(mysql_query("SELECT * FROM gforum_SurveyQuestion WHERE Question_ID = ".$questionID." LIMIT 1;")) or die(mysql_error());
	  $answer =  mysql_fetch_array(mysql_query("SELECT * FROM gforum_SurveyAnswer WHERE Answer_ID = ".$answerID." LIMIT 1;")) or die(mysql_error());
	  echo ("<div class='question' style='clear: both; margin: 15px 0px 15px 0px;'>\n");
	  echo ("<span class='question_topic' style='font-weight: bold'>".$question['Question_Name'].": </span>\n");
	  echo ($answer['Answer_Name']."<br />\n");
	  echo ("<input type=\"hidden\" name=\"qid".$questionID."\" value=\"".$answerID."\" >\n");
	  echo ("</div>\n");
	  $tripwire = 1;
	}
}

if ($tripwire == 0) {
  Header("Location: index.php?empty_set=1");
  die();
}

echo ("<input type=\"hidden\" name=\"uid\" value=\"".$_POST['uid']."\" >\n");
echo ("<input type=\"hidden\" name=\"ip\" value=\"".$_POST['ip']."\" >\n");

echo ("<input type=\"submit\" name=\"Submit\" value=\"SUBMIT\" class='nobutton'>
</form><br/><form name='editSurvey' action='index.php?edit=yes' method='post'><input type=\"submit\" name=\"Submit\" value=\"EDIT ANSWERS\" class='nobutton' >");

foreach($_POST as $questionID => $answerID) {
  echo("<input type='hidden' name='".$questionID."' value='".$answerID."' >\n");
}
echo("<input type='hidden' name='edit' value='true' >");
echo ("</form>");

?> 