Page 1 of 1
header sent even within an if
Posted: Sat Jul 17, 2010 11:12 pm
by linus72982
I have an if block that checks for a certain condition and, if true, sends a header location to redirect to a different page. Problem is, no matter what I do, the header within the if block always get sent. I've even gone so far as to explicitly assign a variable $blah to true and then change the if to only redirect if it's false and it still redirects. I'm stumped, am I missing something basic about the header function?
Re: header sent even within an if
Posted: Sun Jul 18, 2010 12:35 am
by requinix
No, but you may be missing something important about your code.
Post it.
Re: header sent even within an if
Posted: Sun Jul 18, 2010 12:45 am
by linus72982
Code: Select all
<?php
require ('/home/a2027775/public_html/php/facebook.php');
require ("/home/a2027775/public_html/php/ayam_Accounts.php");
$accounts = new Accounts;
$facebook = new Facebook(array(
'appId' => 'CENSORED',
'secret' => 'CENSORED',
'cookie' => true,
));
$session = $facebook->getSession();
$me = null;
if ($session) {
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
}
catch (FacebookApiException $e) {
error_log($e);
}
}
if ($me) {
$logoutUrl = $facebook->getLogoutUrl();
}
else {
$loginUrl = $facebook->getLoginUrl();
}
if ($me) {
session_destroy();
session_start();
$_SESSION['uid']=$uid;
if (!$accounts->isMerged($uid) && ($_GET['type']="newLogged")) {
header('Location: http://www.CENSORED.com/mergeFB.php');
}
elseif (!isset($_SESSION['loggedIn'])) {
$accounts->setFBUserIn($uid);
}
}
?>