Hi All,
I'm currently putting together a pretty simple (I'd hoped) page where users can submit a questionaire online through clicking on radio buttons (indicating a score from 1-9) for each question. If they click "submit" without answering all the questions, the page reloads saying "you didn't answer question 2) for example. However, the problem I'm running into is that I don't know how to keep all their old selections! So if the pager reloads they basically have to start over, which is hardly ideal . Can anyone help? I've included the code below....
if (hasSurveyBeenCompleted ($connection, $user_id))
{
header("location: surveyCompleted.php");
}
//this branch is only triggered once submit has been pressed and the page "re runs" itself.
if (isset($_POST['submit']))
{
if (!isset($POST["questionOne"])){
echo "you didn't fill question 1 out!";
} else if (!isset($POST["questionTwo"])){
echo "you didn't fill question 2 out!";
} else {
$questionOne = $_POST["questionOne"];
$query = "INSERT into sms.new_survey (answerid, user_id , question_one) Values ($council_id, $user_id, $questionOne);";
pg_exec($connection, $query);
// All is good - write info to database and go to main surveys page
header("location: options.php");
}
}
?><html>
<head>
<title>User Info</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="global.css" type="text/css">
</head>
<body class="bg" style="margin:20px;">
<form action="<? echo $_SERVER['PHP_SELF']; ?>" name="userinfoform" method="POST">
<h2><p>Please enter the appropriate responses and then click on the submit button:</p></h2>
<span style="color:#FF0000"></span>
<table width="603" border="0">
<tr>
<td colspan = 9>1. Are company x complying with your original and ongoing brief?</td>
</tr>
<tr>
<td><input type="radio" name="questionOne" value="1">1<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionOne" value="2">2<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionOne" value="3">3<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionOne" value="4">4<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionOne" value="5">5<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionOne" value="6">6<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionOne" value="7">7<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionOne" value="8">8<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionOne" value="9">9<span style="color:#FF0000"></span> </td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td colspan = 9>2. Are company X meeting their deadlines on time?</td>
</tr>
<tr>
<td><input type="radio" name="questionTwo" value="1">1<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionTwo" value="2">2<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionTwo" value="3">3<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionTwo" value="4">4<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionTwo" value="5">5<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionTwo" value="6">6<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionTwo" value="7">7<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionTwo" value="8">8<span style="color:#FF0000"></span> </td>
<td><input type="radio" name="questionTwo" value="9">9<span style="color:#FF0000"></span> </td>
</tr>
<tr>
<td colspan = 9><input name="submit" type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>