Jump to content

Warning: Cannot Modify Headers Error


timothyarden

Recommended Posts

Hi Everyone am having errors with this:

Warning: Cannot modify header information - headers already sent by (output started at /------/--------/public_html/-------------------------.com/--------------------/classes/mobile.php:15) in /------/--------/public_html/-------------------------.com/--------------------/classes/mobile.php on line 6

 

Here is mobile.php


<?php // line 1
// mobile.php // line 2
class mobile_redirection { // line 3
function __construct($pagename = NULL){ // line 4
if(preg_match('/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus|up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i', $_SERVER['HTTP_USER_AGENT'])) { // line 5
if(isset($pagename)){ header('Location: http://www.----------------------------.com/mobile/'.$pagename); } else { header('Location: http://www.-------------------------------.com/mobile/'); } // line 6
} else { // line 7
return false; // line 8
} // line 9
} // line 10
} // line 11

?> // line 13

 

I dont understand why there is an error on line fifteen as it doesn't exist and I dont know whats wrong on line 6.

 

When someone goes to my domain it the index file the error comes up but what should happen is if they are a mobile they are redirected to a mobile sub directory or if they aren't a mobile they should be redirected to form.php.

<?php

// Login or Sign Up

 

require('classes/mobile.php');

$mobile = new mobile_redirection('form.php');

 

if($mobile === false){

header('Location: form.php');

}

 

 

?>

 

Any ideas why this isn't happening?

 

Also, it isnt redirecting to form.php yet but if they get there and submit it will be using sessions: is it okay to use headers to redirect from 1.php to 2.php and then on 2.php start_session()?

 

Thanks for reading and for any help in advance,

Timothy

Link to comment
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.