Возникла некая проблема, если на страницу с помощью echo из php
кода добавляется какой-то контент то всё что было в head
перемещается в body
, и естественно становится не работающим.
Вот пример:
До echo
:
<html>
<head>
<link rel="icon" href="img/favicon.ico" type="image/x-icon">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="css/login.css">
<title>Автризируйтесь, пожалуйста </title>
</head>
<body>
<div class="login">
<h1>LOG IN</h1>
<h3>USE YOUR ACCOUNT </h3>
<h5>Login</h5>
<form method="POST">
<input type="login" name="login" spellcheck="false" required="">
<h5>Password</h5>
<input type="password" name="pass" required="">
<input type="submit" name="b_login" value="LOG IN" id="login">
</form>
</div>
</body>
</html>
После echo
:
<html>
<head></head>
<body>
<div class="error" style="top:0px; height:auto; ">
<p>You account banned until 2519-07-16 08:50:52 GMT Reason: Тест</p>
</div>
<link rel="icon" href="img/favicon.ico" type="image/x-icon">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="css/login.css">
<title>Автризируйтесь, пожалуйста </title>
<div class="login">
<h1>LOG IN</h1>
<h3>USE YOUR ACCOUNT </h3>
<h5>Login</h5>
<form method="POST">
<input type="login" name="login" spellcheck="false" required="">
<h5>Password</h5>
<input type="password" name="pass" required="">
<input type="submit" name="b_login" value="LOG IN" id="login">
</form>
</div>
</body>
</html>
Исходники login.php
<?php
require "includes/db.php";
if (isset($_SESSION['logged'])){
header("Location: profile.php");}
if (isset($_POST["b_login"])){
$user = R::findOne("users", 'login = ?', array($_POST["login"]));
if ($user) {
if (password_verify($_POST["pass"], $user->password)){
if ($user->banned>time()){
$errors[]= "You account banned until ".gmdate("Y-m-d\ H:i:s", $user->banned)." GMT";
if (!empty($user->ban_reason)){
$errors[0] = $errors[0]." Reason: ".$user->ban_reason;
}
} else {
$user->agent = $_SERVER['HTTP_USER_AGENT'];
$user->last_ip = $_SERVER['REMOTE_ADDR'];
$user->last_visit = time();
R::store($user);
$_SESSION["logged"] = array($user->id, $user->login, $user->join, $user->admin, $user->last_visit, $user->avatar);
header("Location: profile.php");
}
} else {
$errors[] = "Wrong password";
}
} else {
$errors[]= "User with this login was not found.";
}
if (!empty($errors)){
echo "<div class=\"error\" style=\"top:0px; height:auto; \"> <p>".$errors[0]."</p> </div>";
}
}
?>
<!DOCTYPE html>
<head>
<link rel="icon" href="img/favicon.ico" type="image/x-icon">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="css/login.css">
<title>Автризируйтесь, пожалуйста </title>
</head>
<body>
<div class="login">
<h1>LOG IN</h1>
<h3>USE YOUR ACCOUNT </h3>
<h5>Login</h5>
<form method="POST">
<input type="login" name="login" spellcheck="false" required>
<h5>Password</h5>
<input type="password" name="pass" required>
<input type="submit" name="b_login" value="LOG IN" id="login">
</form>
</div>
</body>
<html>
.echo
куда надо?<body>