www.webdeveloper.com
Results 1 to 6 of 6

Thread: cannot modify header.

  1. #1
    Join Date
    May 2013
    Posts
    119

    cannot modify header.

    Hi,

    I've build a contact form and it works, but I can't get the thankyou message to appear. I keep getting the following error message which I don't understand as I can see anything wrong with line 46. Any suggestions...I'm new!

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/24/10758824/html/contact.php:2) in /home/content/24/10758824/html/contact.php on line 46

  2. #2
    Join Date
    May 2003
    Posts
    599
    Post the script. Most of the time, this error is generated by a redirect or die when you already echoed something to output.

  3. #3
    Join Date
    Jun 2013
    Posts
    4
    if you using any sort of redirect on that page then you should put ob_start(); in the top of the page and ob_flush(); in the bottom, it should fix the problem for you.

  4. #4
    Join Date
    Oct 2011
    Location
    Pakistan
    Posts
    16
    Dont use any thing regarding this problem

    This Problems Begins when Some output being starts before the header(location : 'http://www.somewebste.com');

    you can simple use the <script>window.location.href="http://www.somewebste.com"</script> ;

    In Place of this It works like a charm try this

  5. #5
    Join Date
    May 2013
    Location
    Surendranagar Gujarat India
    Posts
    55
    <?php
    require_once('web.config.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Login</title>
    <link rel="shortcut icon" href="images/favicon.gif"/>
    <link rel="shortcut icon" href="images/favicon.ico"/>
    <link rel="stylesheet" type="text/css" href="<?php echo SITE_STYLE; ?>"/>
    </head>
    <body>
    <div id="page_effect" style="display:none;">
    <?php require_once('./controls/login/login.control.php'); ?>
    </div>
    </body>
    </html>


    // redirect to destination
    if($user_redirect != 'default')
    {
    header('Location:'.$user_redirect);
    }
    elseif($user_redirect == 'default' && isset($_GET['ReturnURL']))
    {
    $destination_url = $_GET['ReturnURL'];
    header('Location:'.$destination_url);
    }
    else
    {
    header('Location:'.SITE_URL.'login.php');
    }




    Kishor Makwana
    Software Engineer
    Insight Softech
    www.insightsoftech.com

  6. #6
    Join Date
    May 2013
    Location
    London, UK
    Posts
    16
    Quote Originally Posted by noahwilson View Post
    Hi,

    I've build a contact form and it works, but I can't get the thankyou message to appear. I keep getting the following error message which I don't understand as I can see anything wrong with line 46. Any suggestions...I'm new!

    Warning: Cannot modify header information - headers already sent by (output started at /home/content/24/10758824/html/contact.php:2) in /home/content/24/10758824/html/contact.php on line 46
    This error is caused because something is being displayed before line 46 has been called. Remove any HTML, text or white space before this line. The header must be before anything is sent/output to the browser.

    Quote Originally Posted by gaurav.insight View Post
    <?php
    require_once('web.config.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Login</title>
    <link rel="shortcut icon" href="images/favicon.gif"/>
    <link rel="shortcut icon" href="images/favicon.ico"/>
    <link rel="stylesheet" type="text/css" href="<?php echo SITE_STYLE; ?>"/>
    </head>
    <body>
    <div id="page_effect" style="display:none;">
    <?php require_once('./controls/login/login.control.php'); ?>
    </div>
    </body>
    </html>


    // redirect to destination
    if($user_redirect != 'default')
    {
    header('Location:'.$user_redirect);
    }
    elseif($user_redirect == 'default' && isset($_GET['ReturnURL']))
    {
    $destination_url = $_GET['ReturnURL'];
    header('Location:'.$destination_url);
    }
    else
    {
    header('Location:'.SITE_URL.'login.php');
    }




    Kishor Makwana
    Software Engineer
    Insight Softech
    www.insightsoftech.com
    The code above will fail. Notice that HTML code is output BEFORE the PHP header() function. That is invalid.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles