2012-10-30 57 views
-3

我在使用我的login.php文件时收到警告。帮助我删除此警告......----警告:session_start()

警告:session_start()[function.session-start]:无法发送会话缓存限制器 - 已发送的头文件(输出在/ home开始/fundumob/public_html/app_create/index.php:35)在上线/home/fundumob/public_html/app_create/login.php 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"; 
} 

} 
} 

?> 
+0

http://www.google.com/search?q=php+headers+already+sent –

+0

选中此项:http://stackoverflow.com/questions/8028957/warning-headers-already-sent-in- php – 2012-10-30 12:35:49

回答

0

试试这个:

你忘了添加在标题声明后退出()...

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

    } 
} 

?> 
+0

我添加了退出功能,但它仍然无法正常工作。出现同样的警告 –

+0

'<?php session_start();'之前是否有空格在文件的顶部?并且在 include(“lib/config.php”)中是否有空格? <?php decloration之前的文件?最后一件事是检查配置文件是否声明session_start();如果你这样做会导致错误。最后一件事......检查你有的任何回声| print | print_r并注释掉它们,因为这些是可能的原因 – Chris

0

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

检查

0

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

相关问题