0

Possible Duplicate:
Headers already sent by PHP

i have this login script which works fine on my wampserver but when i upload to my webhost i keep getting the error

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php:1) in /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php:1) in /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php on line 2

Warning: Cannot modify header information - headers already sent by (output started at /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php:1) in /data/multiserv/users/988963/projects/2254894/www/admin/processor/login.php on line 20

below is the code:

session_start();
ob_start();
extract($_POST);

include("../admin/includes/connect.php");

$query = "SELECT id,username,password FROM account WHERE username = 
           '$username' and password = '$password'";

$result = mysql_query($query) or die("unable to get query DB");

if ($row = mysql_fetch_array($result)) {
    if ($row) {
        extract($row);

        // create session
        $_SESSION['zen_user'] = 'J@0&fu#iEXHU';
        header("location: ../account.php?id=$id");
        exit();
    } else {
        echo "<script>alert('wrong username or password') ; 
           history.go(-1);</script>";
        exit();
    }
} else {
    echo "<script>alert('wrong username or password') ; history.go(-1);
           </script>";
    exit();
}

ob_end_flush();
Community
  • 1
  • 1

3 Answers3

1

put ob_flush() this at the end instead of ob_end_flush()

engr.waqas
  • 375
  • 4
  • 13
0

maybe your include file (../admin/includes/connect.php) is printing a space or something?

I always double check that you don't have a space behind the php open and close tags in the include files

Bokw
  • 789
  • 1
  • 9
  • 21
0

Put ob_start(); above session_start();.
Also put ob_clean above header("location: ../account.php?id=$id");.

air4x
  • 5,618
  • 1
  • 23
  • 36