I am attempting to build a simple blog script into my webpage, everything is working fine, except, that the page will not redirect after it finished processing. I'm using header to redirect; however, I am not sending any output prior to the call, nor am I getting any sort of usefull error message. The code is below. If anyone has any ideas I'd be glad to hear them, or if you have a better method for redirecting the user (similar to the way this board does it after a new post), that would also rock. BTW, I know that the whole file may not be relevent to the problem I am facing right now, but perhaps there is some output being sent and I am not seeing it, or any error related to it. Thanks 🙂
<?php
session_start();
//Send the user to the login page, if they aren't logged in
if(!$_SESSION['username']) {
echo "<center><font size='5' color='red'><b>PLEASE LOG IN</b></font></center>";
include('./includes/login_form.html');
exit();
}
//Grab the Session vars
foreach($_SESSION as $key => $value) {
$key = $value;
}
//Get Included Files Included :)
$include_dir = $_SERVER['DOCUMENT_ROOT'] . "/fms/includes/";
$include_config = $include_dir . "config.php";
$include_sql = $include_dir . "sql_connect.php";
require($include_config);
require($include_sql);
//Get the $_POST Variables
foreach($_POST as $key => $value) {
$key = addslashes($value);
}
$result = mysql_query("INSERT INTO bcd_blog_post VALUES('','$username','$subject','$message',now())");
if($result) {
header("Location: index.php");
echo "I'm stuck!";
}
else {
echo "There was an error inserting your new blog post:<br>" . mysql_error();
}
?>