我有下面的代碼,但是我在這裏封鎖..PHP登錄頭部位置
<?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; ?>
有人可以幫助我的代碼部分相結合?
我tryed這一點,但告訴我,頭已經發送..
<?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; ?>
如果您在header()之前寫出任何內容(甚至是第一個<?php!之前的空格),您將看到此錯誤。 – idmean
這裏的兩個''塊用正在發送的新行分開。 – Cthulhu
我認識弟弟,這就是爲什麼我要求你的幫助! –