-1

I need help figuring this out. I have a code that later on changes the header location like this:

header('Location: http://www.matrixgamingns.com/changepassword.php?success');

And it's not working. When i used that line i localhost it was ok and it worked like it should. And it looked like this:

header('Location: changepassword.php?success');

And now when it's online it doesn't want to reload or redirect the page. Luckily i have turned error reporting ON and this is what i get:

Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosweb/web039/b397/ipg.matrixgamingnscom/public_html/recover.php:7) in /hermes/bosweb/web039/b397/ipg.matrixgamingnscom/public_html/recover.php on line 44

That's ok i see what's wrong... But When i go to the error that line is my php include. Like this:

<?php include 'php/includes/headstart.php'; ?>

And the craziest part is that in that include i have nothnig that can redirect like the error states. Included php:

<!DOCTYPE html>
<html>

    <head>

        <link rel="stylesheet" href="css/style.css" type="text/css" />
        <link rel="stylesheet" href="css/reset.css" type="text/css" />
        <meta http-equiv="content-type" content="text/html" charset="UTF-8">
        <meta name="language" content="serbian">
        <script src="js/jquery.js"></script>
        <link rel="shortcut icon" href="images/favicon.ico" />

PHP code where the file is included:

<?php 
include 'php/db/connection.php';
include 'php/db/init.php'; 
protect_page();
?>

    <?php include 'php/includes/headstart.php'; ?>



        <title>Matrix Gaming</title>
        <meta name="description" content="Matrix Gaming Internet Cafe je mesto gde mozete doci da se druzite sa prijateljima ili se mozda odlucite da se suprotstavite nekome u nekoj od mnogobrojnih igrica
        u nasoj ponudi">



<?php include 'php/includes/headend.php'; ?>

If anyone can help me, i would apreciate it very much!

Vladimir
  • 613
  • 8
  • 20

3 Answers3

0

This happens because you have sent some output to the browser before calling your header function. Check for whitespaces in your code that can potentially send content to the browser causing all the headers to be sent.

DevZer0
  • 13,433
  • 7
  • 27
  • 51
0

Its likely that you output html before doing the header() call. This is not ok. Headers needs to be sent before any output. If no html is output before, it might be a whitespace or similar that is the issue.

Jite
  • 5,761
  • 2
  • 23
  • 37
0

Remember that the header() function cannot be used after any output was sent! Your inclusion is HTML, meaning it's sending that as output to the browser; header()cannot be used because something was already output.

aaaaaa123456789
  • 5,541
  • 1
  • 20
  • 33