SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Enthusiast Borrow's Avatar
    Join Date
    Jul 2004
    Location
    Australian living in London, UK.
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question page it just simply reloads itself - not redirecting??

    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));
     
    }
    ?>

  2. #2
    ko pročita magarac :) boccio's Avatar
    Join Date
    Oct 2003
    Location
    belgrade
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    header(sprintf("Location: %s", $insertGoTo));

    You have to invoke header() prior to having any output at all. Check for ob_start() function.
    Vivvo CMS - Web publishing at your fingertips
    Mile voli disko, a ja belo kolumbijsko

  3. #3
    SitePoint Enthusiast Borrow's Avatar
    Join Date
    Jul 2004
    Location
    Australian living in London, UK.
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    eerrmmm.... trying to understand this from php.net manual...

    I have to add something like this...?


    ob_start("");

    ob_end_flush();



    Tell me how? :-(

  4. #4
    ko pročita magarac :) boccio's Avatar
    Join Date
    Oct 2003
    Location
    belgrade
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe not...check for the include() functions - they force some output...if it is not needed - delete it. it should work then...

    otherwise, put ob_start() prior to <?include("loggincheck.php");?>, and ob_end_flush() after header()...just a thought...
    Vivvo CMS - Web publishing at your fingertips
    Mile voli disko, a ja belo kolumbijsko

  5. #5
    SitePoint Enthusiast Borrow's Avatar
    Join Date
    Jul 2004
    Location
    Australian living in London, UK.
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    yeah tried that as you mention on second line. still comes up with same error. I am not really quite good at this - need guide on this.

    Have a look at my php code and see those ob_start() and ob_end_flush()....

    PHP Code:
    <?php ob_start();?>
    <?
    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));



    }
    ?>
    <?php ob_end_flush
    ();?>

  6. #6
    SitePoint Enthusiast Borrow's Avatar
    Join Date
    Jul 2004
    Location
    Australian living in London, UK.
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, can anyone please let me know? See my previous message above.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •