Jump to content

problem while using header() function


rageshtly

Recommended Posts

 

i want to use header function in my login page, means if login is correct page it is redirect from one page to other but while using header() i get this error messge

Warning: Cannot modify header information - headers already sent ..........

 

pls tell me how can i solve this problem

 

Link to comment
https://forums.phpfreaks.com/topic/120335-problem-while-using-header-function/
Share on other sites

header(); needs to come before any output, such as HTML.

 

wrong:

<?php
echo "<b>lol</b>";
if($something == $something_else) {
header("Location: redirect.php");
}
?>

 

right:

<?php
if($something == $something_else) {
header("Location: redirect.php");
} else {
echo "<b>lol</b>";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.