Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialWilztan Andrew
Python Web Development Techdegree Student 4,979 Pointsheader redirect error , still on the same page
Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/ecom/admin/includes/head.php:12) in /Applications/MAMP/htdocs/ecom/helpers/helpers.php on line 25
anyone can help me? i got a problem at here
here is my code
function login($user_id){
$_SESSION['SBUser'] = $user_id;
global $db;
$date = date("Y-m-d H:i:s");
$db->query("UPDATE users SET last_login = '$date' WHERE id = '$user_id'");
$_SESSION['success_flash'] = "You are now Log in!";
header("Location: index.php");
}
<?php
require_once '../core/init.php';
if(!is_logged_in()){
login_error_redirect();
}
include "includes/head.php";
include "includes/navigation.php";
?>
Administrator Home
<?php
include "includes/footer.php";
?>
1 Answer
Nathan Tanner
Courses Plus Student 25,250 PointsIdeally, more content of the files would help, but the source of the problem is that the header function "must be called before any actual output is sent" and it looks like head.php is being loaded before the login function runs.
Paul Ryan
4,584 PointsPaul Ryan
4,584 Pointsyou are going to need to show the content of the files you are including, especially init.php.