Jump to content

Two huge session_start() errors


Noskiw

Recommended Posts

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\projects\p_web\index.php:36) in C:\xampp\htdocs\projects\p_web\include\login.php  on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\projects\p_web\index.php:36) in C:\xampp\htdocs\projects\p_web\include\login.php on line 3

 

<?php

session_start();
    
$username = $_POST['username'];
$password = $_POST['password']; 

echo "<br />";

if($_POST['submit']){
    if($username && $password){
        $sql = "SELECT * FROM users WHERE username='".$username."'";
        $res = mysql_query($sql) or die(mysql_error());
        
        $numrows = mysql_num_rows($res);
        
        if($numrows != 0){
            while($row = mysql_fetch_assoc($res)){
                $dbusername = $row['username'];
                $dbpassword = $row['password'];
            }
            
            if($username==$dbusername && md5($password)==$dbpassword){
                echo "You're now <b>Logged In</b> Click <a href='index.php?p=member'><b>here</b></a> to enter the member page!";
                $_SESSION['username']=$username;
            }else{
                echo "Incorrect password!";
            }
            
        }else{
            echo "That user <b>doesn't</b> exist!";
        }
        
    }else{
        echo "Please <b>enter</b> a username and a password!";
    }
}

if(!$_POST['submit']){

?>

<form action="index.php?p=login" method="POST">

    <table>
    
        <h1>Login</h1>
        
        <tr><td>Username: </td><td><input type="text" name="username" /></td></tr>
        <tr><td>Password: </td><td><input type="password" name="password" /></td></tr>
        <tr><td><input type="submit" name="submit" value="Login" /></td></tr>
    
    </table>

</form>

<?php

}

?>

 

I have no idea what is going wrong there. It is a login page... (You probably already guessed that) and it works. It just decided to not work...  :(

Link to comment
https://forums.phpfreaks.com/topic/203840-two-huge-session_start-errors/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.