PHP登录头位置
我有以下代码,但我在这里被阻止PHP登录头位置,php,header,Php,Header,我有以下代码,但我在这里被阻止 <?php require 'members/core/init.php'; $general->logged_in_protect(); if (empty($_POST) === false) { $username = trim($_POST['username']); $password = trim($_POST['password']); if (empty($username) === true || empty($password
<?php
require 'members/core/init.php';
$general->logged_in_protect();
if (empty($_POST) === false) {
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if (empty($username) === true || empty($password) === true) {
$errors[] = 'Sorry, but we need your username and password.';
} else if ($users->user_exists($username) === false) {
$errors[] = 'Sorry that username doesn\'t exists.';
} else if ($users->email_confirmed($username) === false) {
$errors[] = 'Sorry, but you need to activate your account.
Please check your email.';
} else {
if (strlen($password) > 18) {
$errors[] = 'The password should be less than 18 characters, without spacing.';
}
$login = $users->login($username, $password);
if ($login === false) {
$errors[] = 'Sorry, that username/password is invalid';
}else {
session_regenerate_id(true);// destroying the old session id and creating a new one
$_SESSION['id'] = $login;
header('Location: http://www.site.ro/1/index.html');
exit();
}
}
}
?>
以及以下各项:
<?php if ($page == 'login'): ?>
<?php endif; ?>
有人能帮我组合这部分代码吗
我试过了,但告诉我已经发送了
<?php if ($page == 'login'): ?>
<?php
require 'members/core/init.php';
$general->logged_in_protect();
if (empty($_POST) === false) {
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if (empty($username) === true || empty($password) === true) {
$errors[] = 'Sorry, but we need your username and password.';
} else if ($users->user_exists($username) === false) {
$errors[] = 'Sorry that username doesn\'t exists.';
} else if ($users->email_confirmed($username) === false) {
$errors[] = 'Sorry, but you need to activate your account.
Please check your email.';
} else {
if (strlen($password) > 18) {
$errors[] = 'The password should be less than 18 characters, without spacing.';
}
$login = $users->login($username, $password);
if ($login === false) {
$errors[] = 'Sorry, that username/password is invalid';
}else {
session_regenerate_id(true);// destroying the old session id and creating a new one
$_SESSION['id'] = $login;
header('Location: http://www.site.ro/1/index.html');
exit();
}
}
}
?>
<?php endif; ?>
我是php初学者,所以请理解我。
先谢谢你
决心
这是最终代码:
<?php if ($page == 'login'):
require 'members/core/init.php';
$general->logged_in_protect();
if (empty($_POST) === false) {
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if (empty($username) === true || empty($password) === true) {
$errors[] = 'Sorry, but we need your username and password.';
} else if ($users->user_exists($username) === false) {
$errors[] = 'Sorry that username doesn\'t exists.';
} else if ($users->email_confirmed($username) === false) {
$errors[] = 'Sorry, but you need to activate your account.
Please check your email.';
} else {
if (strlen($password) > 18) {
$errors[] = 'The password should be less than 18 characters, without spacing.';
}
$login = $users->login($username, $password);
if ($login === false) {
$errors[] = 'Sorry, that username/password is invalid';
}else {
session_regenerate_id(true);// destroying the old session id and creating a new one
$_SESSION['id'] = $login;
header('Location: http://www.site.ro/1/index.html');
exit();
}
}
}
endif; ?>
一旦将任何内容发送给用户,您就不能修改标题。这包括任何错误的空格或换行符
<?php if ($page == 'login'): ?>
<?php
require 'members/core/init.php';
$general->logged_in_protect();
您的代码中可能有一些空白
你可以找到它
或者最简单的解决方法是打开
输出缓冲允许您做的是回显/打印您想要的任何内容,并且仍然能够将页眉信息发送到页面中的任何位置。如果您写出任何内容(即使是第一个空格和两个
块之前的空格都被发送的新行隔开。我知道兄弟。这就是我请求你帮助的原因!所以你确定在这个登录脚本之前没有内容?没有php警告或通知?这是正确的答案。我尊敬你。干杯,兄弟!事实上,最好是关闭该脚本正确输入并单击Castis答案旁边的白色复选标记,直到它变为绿色,因为它确实是正确的答案。@AvadanicLaudiu
<?php if ($page == 'login'):
require 'members/core/init.php';
$general->logged_in_protect();