Hey,

Looking for some help on this very interesting problem...

My INSERT statement does not INSERT! Woot!

Upon submit, the page it just simply reloads itself, even though i have specified for it to redirect to a 'done' page after adding details on noticeboard form for database...

It came with error message on top saying:

Warning: Cannot modify header information - headers already sent by (output started at /public/www/CMS/cms_head.php:2) in /public/www/CMS/addnoticeboard.php on line 67

It did add details to database with no problem - but it won't redirect to another page after hitting the submit button.

Here is bit of my php code for this.... see if there is any mistake?

PHP Code:
<?include("loggincheck.php");?>
<?php 
require_once('Connections/mysql_connect_cms.php'); ?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

$date_start $_REQUEST['year_start'] . '-' $_REQUEST['month_start']  . '-' $_REQUEST['day_start']; 
$date_expiry $_REQUEST['year_expiry'] . '-' $_REQUEST['month_expiry']  . '-' $_REQUEST['day_expiry'];

  if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "addNoticeboard")) {
  
$insertSQL sprintf("INSERT INTO noticeboard (firstname, surname, email, phone_voice, phone_text, phone_mobile, fax, address_no, address_street, address_towncity, address_postcode, address_county, date_start, date_expiry, title, sub_title, advert, approved) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['firstname'], "text"),
                       
GetSQLValueString($_POST['surname'], "text"),
                       
GetSQLValueString($_POST['email'], "text"),
                       
GetSQLValueString($_POST['phone_voice'], "text"),
                       
GetSQLValueString($_POST['phone_text'], "text"),
                       
GetSQLValueString($_POST['phone_mobile'], "text"),
                       
GetSQLValueString($_POST['fax'], "text"),
                       
GetSQLValueString($_POST['address_no'], "text"),
                       
GetSQLValueString($_POST['address_street'], "text"),
                       
GetSQLValueString($_POST['address_towncity'], "text"),
                       
GetSQLValueString($_POST['address_postcode'], "text"),
                       
GetSQLValueString($_POST['address_county'], "text"),
                       
GetSQLValueString($date_start"text"), 
                       
GetSQLValueString($date_expiry"text"),
                       
GetSQLValueString($_POST['title'], "text"),
                       
GetSQLValueString($_POST['sub_title'], "text"),
                       
GetSQLValueString($_POST['advert'], "text"),
                       
GetSQLValueString($_POST['approved'], "int"));
                       

  
mysql_select_db($database_mysql_connect_cms$mysql_connect_cms);
  
$Result1 mysql_query($insertSQL$mysql_connect_cms) or die(mysql_error());
  
  
$insertGoTo "pages.php?view=addnoticeboard_done";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
 
}
?>