1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Cannot Modify Header Error

Discussion in 'PHP' started by abhi10kumar, Mar 2, 2013.

  1. #1
    I integrated Login with FB and Twitter; but I'm getting error when I click Login in Facebook link
    check at http://delhicertificates.in/
    Warning: Cannot modify header information - headers already sent by (output started at /home/delhioia/public_html/index.php:7) in /home/delhioia/public_html/facebook/index.php on line 12
    /home/delhioia/public_html/facebook/index.php
    <?php
    //Always place this code at the top of the Page
    if (isset($_SESSION['id'])) {
    // Redirection to login page twitter or facebook
    header("location: home.php");
    }

    if (array_key_exists("login", $_GET)) {
    $oauth_provider = $_GET['oauth_provider'];
    if ($oauth_provider == 'twitter') {
    header("Location: login-twitter.php");
    } else if ($oauth_provider == 'facebook') {
    header("Location: login-facebook.php");
    }
    }
    ?>
    <div style='padding-top:5px;'>
    <a href="?login&oauth_provider=twitter"><img src="../img/twitter_signin.png"></a><a href="?login&oauth_provider=facebook"><img src="../img/facebook_signin.png"></a>
    </div>
    -------------------------------------------------------------
    /home/delhioia/public_html/index.php
    <?php
    session_start();
    ?>
    <head><title>Birth, Marriage, Domicile Certificates, Passport, Voter ID Card, Aadhar/UIDAI Card, Driving Licence in Delhi</title>
    <meta name="description" content="Find information, how to apply for Birth, Marriage, Domicile Certificates, Passport, Voter ID Card, Aadhar/UIDAI Card, Driving Licence issued by Delhi Govt.">
    <meta name="keywords" content="birth certificate, marriage, domicile certificate, passport, voter ID card, aadhar/UIDAI card, driving licence">
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <meta name="google-site-verification" content="dZ_1PeO1D2NtRj0IamyazEPbRyAsOrpY33IHVI5TbyU" />
    <link rel="stylesheet" type="text/css" href="style/style.css">
    <script type="text/javascript" src="js/jquery-latest.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    </head>
    <style>
    li{padding-bottom:10px;}
    </style>
    <body>
    <!-- Page Content -->
    </body>
    </html>
     
    abhi10kumar, Mar 2, 2013 IP
  2. cballou

    cballou Member

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    Your first header redirect uses a lowercase l in location. Try fixing that.

    header("Location: home.php");
    PHP:
     
    cballou, Mar 5, 2013 IP
  3. peter_anderson

    peter_anderson Notable Member

    Messages:
    3,382
    Likes Received:
    152
    Best Answers:
    0
    Trophy Points:
    240
    #3
    Also, after every header redirect, add an
    exit();
    PHP:
    , just to be safe.
     
    peter_anderson, Mar 5, 2013 IP
  4. Forbidd3n

    Forbidd3n Well-Known Member

    Messages:
    262
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #4
    abhi10kumar,

    The reason for your error is because you have some sort of space at the top of the script.

    Warning: Cannot modify header information - headers already sent by (output started at /home/delhioia/public_html/index.php:7) in /home/delhioia/public_html/facebook/index.php on line 12

    Check to make sure there are no space or return (new lines) above line 12 in /facebook/index.php

    Also, do what the other said above, change location to Location and exit; after each header statement.
    But this isn't where the error lies.

    Let me know if you still have any issues. If so, please post the data from facebook.php page.

    Thanks,
    Forb
     
    Forbidd3n, Mar 5, 2013 IP
  5. SoftCloud

    SoftCloud Well-Known Member

    Messages:
    1,060
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    120
    #5
    The way I get around this is just under the "<?php" line, just put this in... it's a quick way of fixes the error.
    ob_start();
    PHP:
     
    SoftCloud, Mar 9, 2013 IP
  6. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #6
    The error message tells you exactly where the error is - line 7.
    <?php
    //Always place this code at the top of the Page
    if (isset($_SESSION['id'])) {
    // Redirection to login page twitter or facebook
    header("location: home.php");
    }
     
    if (array_key_exists("login", $_GET)) {
    PHP:
    Line 7 is the blank line. The script outputs a blank line, outputting headers first (that's how the web works - headers before anything else or the browser won't see the "anything else"). Either do it SoftCloud's way or don't send anything until all your headers have been sent. (Location is a header.)
     
    Rukbat, Mar 10, 2013 IP