-2

When i test my website on my localhost it works all fine. But when i test it on my webserver it always come this error:

Warning: Cannot modify header information - headers already sent by (output started at /users/evernet/www/classes/DB.php:139) in /users/asdasd/www/classes/Redirect.php on line 14

   class Redirect {
    public static function to($location = null) {
        if($location) {
            if(is_numeric($location)) {
                switch($location) {
                    case 404:
                        header('HTTP/1.0 404 Not Found');
                        include 'inc/errors/404.php';
                        exit();
                    break;
                }
            }
            header('Location: ' . $location);
            exit();
        }
    }
}

-

require_once 'core/init.php';

$user = new User();
if($user->isLoggedIn()) {
    Redirect::to('index.php');
}

if(input::exists()) {
    if(Token::check(Input::get('token'))) {

        $validate = new Validate();
        $validation = $validate->check($_POST, array(
            'username' => array('required' => true),
            'password' => array('required' => true) 
        ));

        if($validation->passed()) {
            $user = new User();
            $login = $user->login(Input::get('username'), Input::get('password'));

            if($login) {
                Redirect::to('admin.php');
            }else {
                echo '<p>Sorry, logging in failed.</p>';
            }

        }else {
            foreach ($validation->errors() as $error) {
                echo $error, '<br />';
            }
        }
    }
}

.

Mo.
  • 339
  • 5
  • 16

1 Answers1

1

At line /users/evernet/www/classes/DB.php:139 you're outputting some text.

probably something like:

<?php
//some code
?> <------ A space or newline here

Try to remove the ?> if thats the case, you're looking for /users/evernet/www/classes/DB.php on line 139

Richard Deurwaarder
  • 2,023
  • 1
  • 26
  • 40