成功したページに移動する代わりに、スクリプトページで停止し、タイトルに「警告: ヘッダー情報を変更できません - ヘッダーは既に送信されました (出力が開始されました)」というエラーが表示されます。エコーか何かの後にそれを持っていますが、それを修正する方法がわかりません。
<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>