Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.