Page Redirection problem in php -


i want redirect login page main page using php. use following line of code: header('location:index.php'); inspite of redirection received error like:

warning: cannot modify header information - headers sent (output started @ c:\wamp\www\student\login.php:18) in c:\wamp\www\student\login.php on line 19 

this error occures if print before header() function.

for example:

<?php echo 'test'; header('location:index.php'); exit; ?> 

or even:

<html>   <head> ..... <?php echo 'test'; header('location:index.php'); exit; ?> 

you have move piece of php code before operation gives output.

you can following trick second way should try:

<?php echo 'test'; ob_start(); flush(); header('location:index.php'); exit; ?> 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -