That worked, but I’ve now got another question lol.
The answers to the question are updating to my database fine, now before the redirect to the next question I’d like to display a message that says “you got it right/wrong” depending on there answer.
I assume this is some sort of an if statement but i cant quite figure it out.
Below is my insert code at the moment, im assuming this is where the if statement goes.
if ($ch) { // The value I’m passing to the database
// Add product data to the database:
$q = “INSERT INTO questionnaire (indice, q2, time_now)
VALUES (’$ind’, ‘$ch’, now())”;
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n
MySQL Error: " . mysqli_error($dbc));
if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.
echo '<center style="margin-left: 20px; margin-right: 20px"><h2>Thank you! Question 1 completed.</h2></center>';
$_SESSION['page']='';
header('Refresh: 3; URL=nextpage.php);
exit(); // Stop the page.
} else { // If it did not run OK.
echo '<center><p class="error">Attempted duplicate entry. Please Wait!</p></center>';
$_SESSION['page']='';
header('Refresh: 3; URL=nextpage.php);
}
}
mysqli_close($dbc);