Php 无法修改标题信息错误

Php 无法修改标题信息错误,php,mysql,Php,Mysql,它没有将我带到成功页面,而是在脚本页面停止,并在标题“警告:无法修改标题信息-已发送的标题(输出从开始)”中给出错误我相信这和头球有关,而且是在回声或其他东西之后,但我不知道如何修复它。非常感谢任何帮助 <div style="position:absolute;left:750px;top:0px;width:160px;height:41px;overflow:hidden;"> <?php if(isset($_SESSION['userName'])){ echo

它没有将我带到成功页面,而是在脚本页面停止,并在标题“警告:无法修改标题信息-已发送的标题(输出从开始)”中给出错误我相信这和头球有关,而且是在回声或其他东西之后,但我不知道如何修复它。非常感谢任何帮助

   <div style="position:absolute;left:750px;top:0px;width:160px;height:41px;overflow:hidden;">
<?php
if(isset($_SESSION['userName'])){
echo 'You are already logged in as <a href="recent.php" <a>'.$_SESSION['userName'].'</a>. Not you? <a href ="logout.php"</a>logout';
}else{
echo ' Please login <a href ="login_form.php" <a> click here</a>'.' Register <a href="register.php"<a>here</a>';
}

?>  
</div>
<div style="position:absolute;left:400px;top:150px;width:400px;height:141px;overflow:hidden;">
<?php
//=============Configuring Server and Database=======
$host        =    'localhost';
$user        =    'root';
$password    =    'revilo';
//=============Data Base Information=================
$database    =    'dbsneaker';

$conn        =    mysql_connect($host,$user,$password) or die('Server Information is not Correct'); //Establish Connection with Server
 mysql_select_db($database,$conn) or die('Database Information is not correct');

 //===============End Server Configuration============

 //=============Starting Registration Script==========

 $userName    =    mysql_real_escape_string($_POST['txtUser']);

 $password    =    mysql_real_escape_string($_POST['txtPassword']);

 //=============To Encrypt Password===================
//$password    =    md5($password);
//============New Variable of Password is Now with an Encrypted Value========
if(!trim($userName) || !trim($password)){
echo 'Please fill in the form <br> <a href="register.php"<a>Click here</a> to return to registration';
}else{
// There's no empty field
// Check user exists
$checkQuerySql = "SELECT * FROM `bladmin` WHERE `admin_usr_name` = '$userName'";
$checkQuery = mysql_query($checkQuerySql);
if(mysql_fetch_assoc($checkQuery)){
    echo 'User already exists <br> <a href="register.php"<a>Click here</a> to return to registration';
   }else{
    if(isset($_POST['btnRegister'])) //===When I will Set the Button to 1 or Press Button to register
{
$query    =    "insert into bladmin(admin_usr_name,admin_pwd)values('$userName','$password')";
$res    =    mysql_query($query);
header('location:success_register.php');
}// User doesnt exists
}
}



?>
</div>
</div>

请记住,必须在调用任何实际输出之前调用header() 通过普通HTML标记、文件中的空行或PHP发送。 使用include或require读取代码是非常常见的错误, 函数或其他文件访问函数,并具有空格或空 在调用header()之前输出的行。同样的问题也存在 当使用单个PHP/HTML文件时


因此,您需要以在输出任何内容之前调用header的方式重新组织代码。

您的问题的答案很简单,在设置header之前不应该有输出;对于没有真正使用header的新手来说,这是一个常见的错误

<?php
header ("Location: test.php");
?>

这不会抛出错误

<?php
 echo "blabla";
header ("Location: test.php");
?>

测试

以上内容将触发错误。

这是由于顶部的
以及
argh前面的空白造成的。这是一个简单的错误,谢谢您的帮助
<strong> test</strong>
<?php
header ("Location: test.php");
?>