可能重复:
PHP 已发送的标头
我的网站登录表单有问题。在login.php
表格的顶部我有这个
<?php
if (isset($_SESSION['username'])){
header("Location: http://myurl/"); die;}?>
<?php require 'includes/dbconnect.php' ;
?>
<?php require 'includes/header.php'; ?>
当登录成功时,我将它们重定向到
header('Location: http://myrul/');
header.php
拥有
<?php session_start(); ?>
在顶部。
当我尝试登录时,我收到以下错误消息:
警告:无法修改标头信息 - 标头已由第 39 行 /path/to/file/login.php 中的(输出开始于 /path/to/file/login.php:7)发送。
login.php:7 ==><?php require 'includes/header.php'; ?>
尽管
login.php 中的第 39 行是 ==>header('Location: http://myrul/');
请问问题出在哪里
更新我移到require 'includes/header.php
文件的顶部。
<?php require 'includes/header.php';?>
if (isset($_SESSION['username'])){
header("Location: http://murl"); die;}?>
<?php require 'includes/dbconnect.php' ; ?>
更新 2
<?php require 'includes/header.php';?>
<?php if (isset($_SESSION['username'])){
header("Location: http://myurl/"); die;}?>
<?php require 'includes/dbconnect.php' ; ?>
$username = trim ($_POST['username']);
指向$username = trim ($_POST['username']);
为 output started at /path/to/file/header.php:11
更新
头文件.php
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="Your description goes here" />
<meta name="keywords" content="your,keywords,goes,here" />
<meta name="author" content="Your Name" />
<link rel='stylesheet' type='text/css' href='css/theme.css' />
<link rel='stylesheet' type='text/css' href='css/fullcalendar.css' />
<link rel='stylesheet' type='text/css' href='css/fullcalendar.print.css' media='print' />
<link rel="stylesheet" href="css/jquery.tagbox.css" />