I keep getting this error message when I try to 'login' to my php member system that I'm creating.

Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\acrd\includes\header.php:24) in C:\xampp\htdocs\acrd\login.php on line 21

Here is line 21

header('Location: index.php');

Here is my code. Please help!

    <?php
    include 'core/init.php';
    include 'includes/overall/header.php';

    if (empty($_POST) === false) {
        $username = $_POST['username'];
        $password = $_POST['password'];

        if (empty($username) === true || empty($password) === true) {
            $errors[] = 'You need to enter a username and password.';
        } else if (user_exists($username) === false) {
            $errors[] = 'We cannot find that username. Have you registered?';
        } else if (user_active($username) === false) {
            $errors[] = 'You have not activated your account.';
        } else {
            $login = login($username, $password);
            if ($login === false) {
                $errors[] = 'That username/password combination is incorrect.';
            } else {
                $_SESSION['user_id'] = $login;
                header('Location: index.php');
                exit();
            }
    }
        print_r($errors);
    }
    include 'includes/overall/footer.php';
    ?>

Recommended Answers

Call ob_start at top file

ob_start();
Jump to Post

All 3 Replies

Call ob_start at top file

ob_start();

I added it to the top of the login.php file and it didn't work :(

I finally got it! Thank you. I had to put in <?php ob_start();?>
Maybe because I'm using Dreamweaver.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.