-1

Screenshot

Problem : Headers simply not redirecting to the final.php page.

Tried methods :

  1. there are no header already sent errors.
  2. Checked the whitespaces in all the files.
  3. the folder structure is intact.
  4. used full path

    header("Location:localhost:81/2php_quizzer/final.php");

but still shows blank page

  1. the $number and $total values are the same.

  2. tried other pages instead of final.php still not working.

if ($number == $total) { echo $number . "=" . $total; // testing header("Location : final.php"); // tried using header("Location :localhost:81/2php_quizzer/final.php"); exit(); } else { // redirect to the next question header("Location: questions.php?n=" . $next); }

What worked so far.. the else block is working fine

So, after completing the two questions. The user should be redirected to final.php page containing "test complete " message however the page is still blank and stuck at process.php.

  • Try with `header("Location:2php_quizzer/final.php");` or `header("Location:final.php");` – Nana Partykar Jun 06 '16 at 18:44
  • 1
    See [How do I get PHP Errors to display?](http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) and then [How to fix “Headers already sent” error in PHP](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – HPierce Jun 06 '16 at 18:48
  • 2
    "there are no header already sent errors." is inconsistent with `echo $number . "=" . $total;` – HPierce Jun 06 '16 at 18:50

1 Answers1

1

No output must be sent before the redirection takes place. So that is exactly what you are doing with the echo. Try removing or commenting the line before your redirection.

// echo $number . "=" . $total; // testing
cachique
  • 1,150
  • 1
  • 12
  • 16
  • i'm pretty sure he is just using that for testing to verify he gets into the if statement. The colon `:` needs to be right after `Location`. This is why the `else` works and the `if` does not. Change `"Location : final.php"` to `"Location: final.php"` – bassxzero Jun 06 '16 at 18:58
  • the echo $number is just for testing purposes and it does not generate any errors.Yup the "location: final.php" colon seems to be the problem. Thanks very much – anil thapa Jun 07 '16 at 01:53