Jump to content

Redriect problems


jameshm26

Recommended Posts

Hi! Im having some problems with getting a redirect to work and for the life of me i have no idea why. Ive got a function been pulled in from a separate php page, and ive also got a session page all set up.

 

What i want to happen is for the page to redirect to login if you try to get to a page that you have got to by logging in.

Basically when i clear cookies and refresh staff.php i get this message:

 

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\widget_corp\includes\header.php:10) in C:\wamp\www\widget_corp\includes\functions.php on line 23

 

Here are the function and staff page code:

 

function.php:

 

function redirect_to( $location = NULL ) {

if ($location != NULL) {

header("Location: {$location}");

exit;

}

}

 

staff.php:

 

<?php require_once("includes/session.php"); ?>

<?php require_once("includes/functions.php"); ?>

<?php include("includes/header.php"); ?>

<?php

if (!isset($_SESSION['user_id'])){

redirect_to("login.php");

}

?>

 

 

Be great if anyone could shed some light on this. Thanks!

Link to comment
https://forums.phpfreaks.com/topic/87535-redriect-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.