Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: modify header

  1. #1
    New Coder
    Join Date
    Sep 2011
    Location
    Blackpool
    Posts
    53
    Thanks
    7
    Thanked 1 Time in 1 Post

    modify header

    Hello people of codingforums I am having a problem with this "Cannot Modify Header Information". I know that extra blank lines can cause this problem but I just can't see where they are. They're bugging me an if you login here, you will receive the error. I dont seem to have this error on localhost but on my website I do?

    This is the error:
    Warning: Cannot modify header information - headers already sent by (output started at /home/connor/public_html/game/includes/top.php:11) in /home/connor/public_html/game/login.php on line 18
    Top.php:
    Code:
    <? 
    if(session_id() == ""){ session_start(); } 
    ?><html><head>
    <link rel="icon" href="images/favicon.ico" type="image/x-icon">
    <title> Cyber States - A online state simulation game.</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <LINK REL=stylesheet HREF="style.css" TYPE="text/css">
    <meta name="robots" content="all">
    <meta name="revisit-after" content="7 days">
    <meta name="author" content="connor mcgarty-wood">
    <meta name="keywords" content="games, gaming, cyber, states, cyberstates, simulation, simulate, online, top, 100, interesting, internet, bored, game, windows, browser game, browser">
    <meta name="description" content="A online simulation game built on the topic of owning your own state. It is online
    and you simulate everyday and collect taxes. This is a very interesting simulation browser games.">
    </head>
    <body>
    <div id="header">
    <img src="images/cyberstates.jpg" ALT="Cyberstates">
    </div>
    <center>
    /* adds */
    </center>
    <br />
    Login.php
    Code:
    <? 
    include('includes/top.php');
    include('includes/menu.php'); 
    $error="";
    if(isset($_SESSION['username'])){
    header('location:default.php');
    }
    if(isset($_POST['login'])) {
    include('includes/connect.php');
    $username = $_POST['username'];
    $password = md5($_POST['password']);
    $query = "select * from users where username='$username' and password='$password'";
    $result = mysql_query($query);
    if (mysql_num_rows($result) != 1) {
    $error = "Your username or password was Incorrect.";
    } else {
        $_SESSION['username'] = $_POST['username'];
    	header('Location: loggedin.php');
    } } 
    ?>
    <div id="rightbox">
    <H2>Login</H2>
    <? 
    if(!$error == ""){
    echo "<div class='error_message'>";
    echo "$error";
    echo "</div>";
    } 
    ?>
    <center>
    <form method="post" action="<?=$_SERVER['PHP_SELF']?>">
    <p> Login into the game below or register <a href="register.php" title="register here">here</a>. You need to allow cookies and javascript, some firewalls
    may block cookies. </p>
    <p> Username: <input name="username" id="username" title="Username" value="" size="30" maxlength="16" /><br /></p>
    <p> Password: <input name="password" id="password" type="password"  title="Password" value="" size="30" maxlength="24" /><br /></p>
    <input type="submit" name="login" value="Login" title="Login into the Game">
    </form>
    </center>
    <? 
    include('includes/bottom.php'); 
    ?>
    Subscribe to a channel dedicated to helping people learn HTML, PHP & CSS.
    http://www.youtube.com/user/RanTutorials

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    You cannot send anything before modifying header information. This includes most of the content of top.php

    Either move header() much earlier in the code-order, or investigate output buffering:
    ob_start() and ob_end_flush().

    ..and the center tag is defunct?!
    Last edited by AndrewGSW; 08-28-2012 at 05:37 AM.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS

  • #3
    New Coder
    Join Date
    Sep 2011
    Location
    Blackpool
    Posts
    53
    Thanks
    7
    Thanked 1 Time in 1 Post
    Grrr the error wont go away:/
    Subscribe to a channel dedicated to helping people learn HTML, PHP & CSS.
    http://www.youtube.com/user/RanTutorials


  •  

    Posting Permissions

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