Hey all, so recently I have been setting up a little quiz in PHP and it runs off of a counter. When a user gets a question right the counter goes up and displays the next question if not the counter returns to 0 and sets the user back to the first question to start over. I decided to add echos of html image code so when the user gets a question right it will display an image according to what the answer is. Doing this however broke my redirect, I basically had it set up so when it reaches the last question it redirects to a page and it was working until the addition of the images. Here is my total php code for not including the arrays as they are not important for my issue:
// current question
$currentQuestion = 0;
if(isset($_POST["currentQuestion"])){
$currentQuestion = $_POST["currentQuestion"];
if(isset($questionsAndAnwsers[$currentQuestion])){
$currentAnswer = $questionsAndAnwsers["$currentQuestion"]["answer"];
if($currentQuestion==17){
header("Location: http://students.purchase.edu/martin.mcnicholas/scriptingfortheweb/index2.html"); /* Redirect browser */
exit();
}else if($_POST["guess"] == $currentAnswer){
$currentQuestion++;
$guess = $_POST['guess'];
print ("<span class='Stylize2'>Your answer: $guess <br>");
print("The answer expected: $currentAnswer<br>");
print("Answer Correct $answerCorrect<br><br>");
if($currentQuestion==1){
echo '<img src=MickeyMouse.png height="200"><br><br>';
}
if($currentQuestion==2){
echo '<img src=Philo.jpg height="200"><br><br>';
}
if($currentQuestion==3){
echo '<img src=warner.jpg height="200"><br><br>';
}
if($currentQuestion==4){
echo '<img src=superman.jpg height="200"><br><br>';
}
if($currentQuestion==5){
echo '<img src=own.jpg height="200"><br><br>';
}
if($currentQuestion==6){
echo '<img src=scooby.png height="200"><br><br>';
}
if($currentQuestion==7){
echo '<img src=garfield.jpg height="200"><br><br>';
}
if($currentQuestion==8){
echo '<img src=pok1.jpg height="200"><br><br>';
}
if($currentQuestion==9){
echo '<img src=peanuts.jpg height="200"><br><br>';
}
if($currentQuestion==10){
echo '<img src=sam.jpg height="200"><br><br>';
}
if($currentQuestion==11){
echo '<img src=haim.jpg height="200"><br><br>';
}
if($currentQuestion==12){
echo '<img src=back.jpg height="200"><br><br>';
}
if($currentQuestion==13){
echo '<img src=joe.jpg height="200"><br><br>';
}
if($currentQuestion==14){
echo '<img src=r.png height="200"><br><br>';
}
if($currentQuestion==15){
echo '<img src=wild.jpg height="200"><br><br>';
}
if($currentQuestion==16){
echo '<img src=car54.png height="200"><br><br>';
}
print("Next Question Below<br></span><br><br>");
}
else {
$currentQuestion=0;
$guess = $_POST['guess'];
print ("<span class='Stylize'>Your answer: $guess <br>");
print("You have failed..<br>");
echo '<img src=angry.gif height="200"></span><br><br>';
}
}else{
exit("Question not found!");
}
}
As soon as the if statements for the images were added it no longer works and I don’t understand why.