-2

I am very new to programming, a website someone else had built for me has stopped working. I am trying to find out what it could be. I did read about it but the explanations are too complicated for me as i dont know enough about programming.

Warning: Cannot modify header information - headers already sent by (output started at /home/username/domain/index.php:3) in /home/username/domain/controllers/register.php on line 31

The code for register.php

header("Location: ".URL."register-missing"); // line 31
    exit(); 
} 


header("Location: ".URL."register");
    exit();
}

The code for index.php

<?php

    class Index extends Controller { // line 3

        function __construct() {
            parent::__construct();
        }

        function index() {      
            $this->view->render('index/index');
        }
    }
?>
Rahil Wazir
  • 10,007
  • 11
  • 42
  • 64

2 Answers2

0

You'd have to check if any thing echoes or prints before the header redirect is called. It's always a good practice to handle header redirects at the beginning of the page, before any other logic is executed. Also try to avoid to include any files before header redirect

Santosh Achari
  • 2,936
  • 7
  • 30
  • 52
0

It looks to me like you are using some type of PHP MVC framework. Check and see if your framework has a "routes" feature, and if so, see if you can use the routing feature to do your redirects instead of manually doing it inside your controller. It's hard to help you though with what you've posted. Did you post the full contents of your register controller?

Yoseph
  • 608
  • 9
  • 22