Hello All,
I'm working on session and I'm getting this warning. Maybe someone can
help fixing this problem. Below is the following code.

Warning: 
Warning: session_start() [function.session-start]: Cannot send session
cookie - headers already sent by (output started at
/var/www/html/bonham/cornerstone-data/property/adminlogin.php:2) in
/var/www/html/bonham/cornerstone-data/property/adminlogin.php on line
3

Warning: session_start() [function.session-start]: Cannot send session
cache limiter - headers already sent (output started at
/var/www/html/bonham/cornerstone-data/property/adminlogin.php:2) in
/var/www/html/bonham/cornerstone-data/property/adminlogin.php on line
3


Then I get my login fields.

Code:
<?php 
         session_start();
         require("functlib.php"); 
   ?>
   <html>
   <head>
         <title>CIS166AE - Admin Login</title>
         <link rel="stylesheet" type="text/css" href="/../../css/table.css">
   </head>
   <body>
   
   
   <?php
         if(isset($_POST['txtUser']) && isset($_POST['txtPass']))
         {      
                  if(CheckUser($_POST['txtUser'],$_POST['txtPass']))
                $_SESSION['valid_user']=$_POST['txtUser'];  
         }
         
         if(CheckAuth()==false)
         {
         //Code to make authentication
         ?>
        <form method="post" action="adminlogin.php" name="login">
        Please Login
        Username:
        <input name="txtUser" type="text">
        Password:
        <input name="txtPass" type="password">
        <input type="submit" value="Login">
        <input type="reset" value="Clear">"
        </form>
        <?php
        }
        else
        {
                //Code if authenticated
                echo "Thank you, you have been authenticated as
<b>".$_SESSION['valid_user']."</b><br>";
                                          
        }
                ?>
                
                <?php if(isset($_SESSION['valid_user'])){echo "<a
href=\"adminlogout.php\">Logout</a>";}?>
        
</body>
</html>

Function FIle:
<?php
//PHP Functions that can be included in pages

function CheckAuth()
{
        if(isset($_SESSION['valid_user']))
                return true;
        else
                return false;
}

function CheckUser($username, $password)
{
                $db = new mysqli('localhost','bonham','password_goes 
here','bonham');
                
                $sql="Select * from auth where username = '".$username."' and
                password = '".$password."'";
                $result=$db->query($sql);
                $db->close();
                if($result->num_rows>0)
                        return true;
                else
                        return false;
}

?>

Thank for the help.
Thomas
-- 
------------------------------------------------------------------
Thomas Bonham
[EMAIL PROTECTED]
bonhamlinux.org
Cell 602-402-9786

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to