Need help

Discussion in 'PHP' started by Kushmair, Dec 25, 2009.

  1. #1
    i need help in the below code i take one check box when someone check it then its will be redirect to given page if false then its will give message please check the box but when its true i want to redirect to given page but its giving error.


    <?

    if ($_GET['action'] == Submit)
    {
    if($_POST['Agree'] == Yes)
    {

    header("Location: index.php");

    }
    else
    {

    echo "Agree Please";

    }

    }


    ?>

    error


    Warning: Cannot modify header information - headers already sent by (output started at D:\Apache\htdocs\site\site\agreement.php:7) in D:\Apache\htdocs\site\site\agreement.php:7 on line number.
     
    Kushmair, Dec 25, 2009 IP
  2. Gray Fox

    Gray Fox Well-Known Member

    Messages:
    196
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #2
    It says that the output has started in D:\Apache\htdocs\site\site\agreement.php on line 7, so it can't send headers, try to delete any space before <?php and after ?>, or better yet, delete PHP closing tag, ?>. One alternative is that you turn on output buffering.
     
    Gray Fox, Dec 25, 2009 IP
  3. Arttu

    Arttu Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    8
    Trophy Points:
    40
    #3
    header("Location: index.php"); must be executed before outputting anything.
     
    Arttu, Dec 25, 2009 IP