警告:session_start()

时间:2012-10-30 12:33:32

标签: php warnings

使用login.php文件时收到警告。帮我删除这个警告......----

  

警告:session_start()[function.session-start]:无法发送会话缓存限制器 - 已在/ home / fundumob /中发送的报头(输出从/home/fundumob/public_html/app_create/index.php:35开始)第1行的public_html / app_create / login.php

 <?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";
}

 }
 }

 ?>

3 个答案:

答案 0 :(得分:0)

试试这个:

你忘了在标题声明后添加一个exit()......

<?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";
        }

    }
}

?>

答案 1 :(得分:0)

你不能在这里使用session_start(),在你的警告中写的/home/fundumob/public_html/app_create/index.php:35中已经输出了一些东西

检查

答案 2 :(得分:0)

如果您要在<?php session_start();?>上方添加任何其他文件,请确保第一行中最顶层文件中存在<?php session_start();?>。可能是你的config.php或你包含的其他文件。