#1
  1. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    I'm busy with a guestbook which can check users IP-address (and compares it with a table containing 'forbidden' IP's), validation of the form-fields and the proper use of language. Depending on what the result are when doing this check, a user is redirected to another page (message telling user he/she is on banlist and should contact administrator, opportunity to complete the data in the form etc).

    The page netbook_add.php (page called from vw_netbook.php to add the data inserted in the form) contains the following code at the end to relocate to a following page:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    if ( $status == 'accepted' ) {
    print( "1" );
    header( "Location: $CFG->wwwroot/vw_netbook.php?pagina=1" );
    exit;
    }

    // niet compleet -> herinvulveld
    else if ( $status == 'incomplete' ) {
    print( "2<br>" );
    $location = "$CFG->wwwroot/vw_netbook.php";
    print( $location."<br>" );
    //header( "Location: $location" );
    header( "Location: $location" ); //this is line 100
    exit;
    }

    // niet geaccepteerd: IP, taal
    else if ( $status == 'denied' ) {
    if ( $reason == 'language' ) {
    print( "3" );
    header( "Location: $CFG->wwwroot/netbook/netbook_denied.php?reason=language" );
    exit;
    }
    else if ( $reason == 'ip' ) {
    print( "4" );
    header( "Location: $CFG->wwwroot/netbook/netbook_denied.php?reason=ip" );
    exit;
    }
    else {
    }
    }
    else {
    }
    [/quote]

    When executing this page it results in the following error:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
    IP check: passed
    Validation check: missing message
    2
    'some url to the page'/vw_netbook.php

    Warning: Cannot add header information - headers already sent in 'some url to the page'/netbook/netbook_add.php on line 100
    [/quote]

    Unfortunately I have no idea what's wrong with the script... It worked before but somehow it doesn't anymore. Does anyone have an idea what I'm doing wrong? If I forgot to mention some important lines here let me now too. Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    63
    Rep Power
    15
    else if ( $status == 'incomplete' ) {
    print( "2<br>" );
    $location = "$CFG->wwwroot/vw_netbook.php";
    print( $location."<br>" );
    //header( "Location: $location" );
    header( "Location: $location" );
    exit;
    }

    For this to work, the line header( "Location: $location" ); has to be the very first thing sent. If you have "whitespace" or any text before this, it will generate this error.

    Try:

    if ( $status == 'accepted' ) {
    header( "Location: $CFG->wwwroot/vw_netbook.php?pagina=1" );
    exit;
    } else if ( $status == 'incomplete' ) {
    $location = "$CFG->wwwroot/vw_netbook.php";
    header( "Location: $location" );
    exit;
    } else if ( $status == 'denied' ) {
    if ( $reason == 'language' ) {
    header( "Location: $CFG->wwwroot/netbook/netbook_denied.php?reason=language" );
    exit;
    } else if ( $reason == 'ip' ) {
    header( "Location: $CFG->wwwroot/netbook/netbook_denied.php?reason=ip" );
    exit;
    } else {
    }
    } else {
    }

    [This message has been edited by chris22 (edited September 09, 2000).]

    [This message has been edited by chris22 (edited September 09, 2000).]
  4. #3
  5. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    Ok, thanx!! It works now...
    Has some logic in it as well

    Mirax

Similar Threads

  1. Very strange DNS error
    By mjs3434 in forum DNS
    Replies: 11
    Last Post: December 24th, 2006, 01:16 AM
  2. Codepupil
    By Adachic in forum C Programming
    Replies: 3
    Last Post: February 6th, 2004, 06:50 PM
  3. syntax error : identifer 'Hole'
    By bootrecker in forum C Programming
    Replies: 2
    Last Post: February 2nd, 2004, 08:08 AM
  4. Replies: 4
    Last Post: January 28th, 2004, 08:29 AM
  5. I don't know what this error message means
    By lcham02 in forum Java Help
    Replies: 2
    Last Post: January 13th, 2004, 11:57 AM

IMN logo majestic logo threadwatch logo seochat tools logo