我正在尝试创建一个登录页面,但我似乎无法显示标题。
session_start();
$_SESSION['prevURL'] = $_SERVER['REQUEST_URI'];
if(!$_SESSION['set'])
{
header("location: main_login.php");
}
答案 0 :(得分:1)
这一行:
if(!$_SESSION['set'])
如果未设置该集,将生成警告。警告生成输出并发送标头。标头已经发送后,您无法设置标头。
修复将使用isset()功能:
if(!isset($_SESSION['set']))
答案 1 :(得分:1)
根据您的评论。您无法在Session_start();
之前显示(打印,回显)HTML<!DOCTYPE html>
<html>
<?php
session_start();
$_SESSION['prevURL']=$_SERVER['REQUEST_URI'];
//make this $_SESSION[ 'adminSet'] if it 's an admin-only page
if(!isset($_SESSION['set'])) {
header("location: main_login.php"); }
?>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> </script>
<script src="/bootstrap/js/bootstrap.js"> </script>
<script src="/bootstrap/js/bootstrap.min.js"> </script>
应改为:
<?php
session_start();
$_SESSION['prevURL']=$_SERVER['REQUEST_URI'];
//make this $_SESSION['adminSet'] if it 's an admin-only page
if(!isset($_SESSION['set'])) {
header("location: main_login.php"); }
?>
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> </script>
<script src="/bootstrap/js/bootstrap.js"> </script>
<script src="/bootstrap/js/bootstrap.min.js"> </script>