【发布时间】:2012-03-04 20:51:55
【问题描述】:
我是 php 的初学者,我搜索了几个小时并尽我所能尝试但仍然出现此错误。 警告:session_start() [function.session-start]:无法发送会话缓存限制器 - 已在 /home/apsterne/public_html/mag 中发送标头(输出开始于 /home/apsterne/public_html/mag/main.php:1) /includes/functions.php 在第 3 行
这是我的登录页面,我正在登录并进入主页
include_once('includes/functions.php');
include_once('includes/connection.php');
if(loggedin())
{
header("location:main.php");
exit();
}
if (isset($_POST['submit'])){
$error=array();
if($_POST['username']=="") $error[]='Please Enter Username';
if($_POST['password']=="") $error[]='Please Enter Password';
if(isset($_GET['e'])) $error[]='You Are Trying to access secure page without login';
if(isset($_POST['rememberme'])) $remember=$_POST['rememberme'];
function cleanStr($str) {
$cStr = trim($str);
$cStr = htmlspecialchars($cStr);
$cStr = addslashes($cStr);
return $cStr;
}
$userName = cleanStr($_POST['username']);
$pwd = cleanStr($_POST['password']);
$result=mysql_query("SELECT * FROM login WHERE username = '$_POST[username]'");
$row=mysql_fetch_array($result);
if(empty($error)){
if($userName==$row['username'] && $pwd==$row['password'] ){
if($rememberme=="on")
setcookie("username",$userName,time()+7200);
else if($rememberme==""){
$_SESSION['username']=$userName;
header("location:main.php");
exit();
}
}
else
$error[]='You Enter Wrong username and password';
}
}
这是主页
<?php
include_once('includes/functions.php');
include_once('includes/connection.php');
if(!loggedin())
{
header("location:index.php");
exit();
}
?>
这是函数文件
<?php
session_start();
function loggedin()
{
if(isset($_SESSION['username']) || isset ($_COOKIE['username']))
{
$loggedin=TRUE;
return TRUE ;
}
}
?>
没有空格,我不知道这是什么..
【问题讨论】:
-
我只需将所有内容复制到新文件中,然后它就可以为我工作 感谢所有 stackoverflow 成员......它是 BOM
标签: php