Posted by Angelos on 05/13/05 13:08
Hello again... I was wondering is there any way to check or output in the
errors string which file or where in my code the headers have been sent ?
I am trying to use this script
*******************************************************************************************
function redirect($url) {
if(!headers_sent()) {
header('Location: http://'.$_SERVER['HTTP_HOST'] .
dirname($_SERVER 'PHP_SELF']) . '/' . $url);
}
else {
die('Could not redirect; Headers already sent.');
}
}
*********************************************************************************************
But no luck in some redirect attempts. It works in some files but I can't
figure out when it doesn't work.
bellow is a part of the code that it doesn't work
***************************************************************************
<? require_once 'http.php'; ?> <====HEre is the Redirection Function
<?php require_once('db_conn.php'); ?>
<? session_start(); ?><? header("Cache-control: private"); // IE 6 Fix. ?>
<?
if (isset($_REQUEST['contcat']) && isset($_REQUEST['action'])) {
switch ($_REQUEST['contcat']) {
case 'content':
switch ($_REQUEST['action']) {
case 'add_webpage':
printf (($_POST['title']) . ($_POST['Contentbody']) .
($_SESSION['user_id']));
if (isset($_POST['title']) and
isset($_POST['Contentbody']) and isset($_SESSION['user_id'])) {
mysql_select_db($db, $db);
$sql = "INSERT INTO bla bla bla";
mysql_query($sql, $db) or die('Could not
content'.mysql_error());
}
redirect('index.php'); <<<<<=================
break;
default:
break;
}
default:
break;
}
}
***************************************************************************
I would really appreciate some help.
Thanks Angelos.
Navigation:
[Reply to this message]
|