Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default [PHP] Whats wrong with this?

    G'day y'all.. Why doesn't this code work? Well, it works but I can't have this part..
    HTML Code:
    <!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>Testing</title>
    </head>
    
    <body>
    PHP Code:
    <?php session_start(); ?> 
    <!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>Testing</title>
    </head>

    <body>
    <?php


    // Includes the mysql connection page
    include("includes/connect.php");

    // Check if the submit button was pressed
    if (isset($_GET['submit'])) {
        ..
        }else{
                
    $_SESSION['user_id'] = $user_id;
     
                
    // Redirect to userpanel.php
                
    header('location: userpanel.php');
            }
        }

    }else{
        ...

    ?><br />
    </body>
    </html>
    Why is it that that doesn't work? (obviously there is more coding than just that. The error I get is:
    Warning: Cannot modify header information - headers already sent by (output started at /home/username/public_html/members/login.php:10) in /home/username/public_html/members/login.php on line 37


    line 10: <?php
    line 37: header('location: userpanel.php');

    +rep when i can

  2. #2

    Default

    Well besides your opening and closing tags seem to be incorrect in the second block of PHP, the problem is you're redirecting after the headers are sent as the error states, to fix this simply add at the top prior to session_start(); "ob_start();" this will turn output buffer on and will stop your error.

    e.g.
    PHP Code:
    <?php

    ob_start
    ();
    session_start();

    ?>
    Last edited by Iszak; 14-11-2008 at 04:39 AM.

  3. #3
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    okay thanks!! And what do you mean by "your opening and closing tags seem to be incorrec"?

  4. #4

    Default

    Sorry - yeah I worded that badly.
    PHP Code:
    <?php


    // Includes the mysql connection page
    include("includes/connect.php");

    // Check if the submit button was pressed
    if (isset($_GET['submit'])) {

        }else{
                
    $_SESSION['user_id'] = $user_id;
     
                
    // Redirect to userpanel.php
                
    header('location: userpanel.php');
            }
        }

    }else{


    ?>
    That code has closing brackets "}" that you don't need and also is missing one for the last else.

  5. #5
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    oh yeah, sorry! I just removed half of the code ! It all works now, i'll +rep you when this stupid caution is removed -.-'

Posting Permissions

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