-3

I have received a warning when using my login.php file. help me to remove this warning......----

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/fundumob/public_html/app_create/index.php:35) in /home/fundumob/public_html/app_create/login.php on line 1

 <?php session_start();?>
 <?php 
 include("lib/config.php");

 if(isset($_POST["tb_login"]))
 {
 $myusername=$_POST['log_email'];
 $myuser_password=$_POST['log_password']; 

 if(!empty($myusername) && !empty($myuser_password))  
  {
 $sql="SELECT * FROM act_member WHERE   password='$myuser_password' and               
  email='$myusername'";
$result=mysql_query($sql);
 // Mysql_num_row is counting table row
 $count=mysql_num_rows($result);
 // If result matched $myusername and $mypassword, table row must be 1 row
 if($count==1){
 $rows=mysql_fetch_row($result);
 $_SESSION['user_id']= $rows[0];
 $_SESSION['mem_id']=$rows[1];
 $_SESSION['fname']=$rows[2];
 $_SESSION['lname']=$rows[3];
 header("location:profile.php");    }
 else { 

echo "sorry you entered wrong password or email id";
}

 }
 }

 ?>
air4x
  • 5,618
  • 1
  • 23
  • 36

3 Answers3

0

Try this:

You forgot to add an exit() after the header declaration...

<?php 

session_start();
include("lib/config.php");

if(isset($_POST["tb_login"])){

    $myusername=$_POST['log_email'];
    $myuser_password=$_POST['log_password']; 

    if(!empty($myusername) && !empty($myuser_password)){
        $sql="SELECT * FROM act_member WHERE   password='".$myuser_password."' and               
        email='".$myusername."'";
        $result=mysql_query($sql);
        // Mysql_num_row is counting table row
        $count=mysql_num_rows($result);
        // If result matched $myusername and $mypassword, table row must be 1 row

        if($count==1){

            $rows=mysql_fetch_row($result);
            $_SESSION['user_id']= $rows[0];
            $_SESSION['mem_id']=$rows[1];
            $_SESSION['fname']=$rows[2];
            $_SESSION['lname']=$rows[3];
            header("Location: profile.php");    
            exit(); // <-------------------- add this else the page will not redirect and you will get a header error
        }
        else { 
            echo "sorry you entered wrong password or email id";
        }

    }
}

?>
Chris
  • 5,516
  • 1
  • 26
  • 30
0

you cannot use session_start() here, something is already outputting in /home/fundumob/public_html/app_create/index.php:35 as written in your warning

check it

vladkras
  • 16,483
  • 4
  • 45
  • 55
0

if you are including any other file above <?php session_start();?>, make sure <?php session_start();?> exists in top most file on first line. Probably your config.php or some other file that you include.

codefreak
  • 6,950
  • 3
  • 42
  • 51