How can I "set headers before I do anything else" if there's stuff I need to do on this page before I redirect?
1] Parse querystring.
2a] If querystring contains 'Command=Save' then save all form data from querystring, then redirect to homepage.
2b] If querystring contains 'Command=Continue' then save all form data, then redirect to page 2 using a form to pass some variables.
Thus:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Write Answers</title>
<?php
$section = $_POST['section'];
$UID = $_POST['UID'];
$SaveExit = $_POST['SaveContinue'];
#message data, open database connection
#...
$sql = "INSERT INTO `Aura_User_Answer` (UserID, QuestionID,Answer) VALUES (".$UID.",".$QuID.",".$Ans.")";
$result = mysql_query($sql);
$result = mysql_query($sql);
mysql_close($dbcnx);
# close
if ($SaveExit=="Save"){
# Save/Exit flag was set to Save
header("Location: index.html");
}
else{
# Save/Exit flag was set to Continue
?>
</head>
</body>
<!-- hereafter, build a form so you submit form data for POSTing -->
So, regardless of what happens later in the page, it chokes on the 'header' line.