我正在编写一个基本的授权系统,但我有点挣扎。涉及两个文件 -index.php
and login.php
。登录表单非常简单(它在里面index.php
):
<fieldset class="right">
<label for="email">Email
<input id="email" name="email" type="text" value=""/>
</label>
<label for="password">Password
<input id="password" name="password" type="password" />
<a href="#" onclick="$('#password-box').toggle();" >Forgot your password?<span></span></a>
</label>
<div class="btn-login"><button type="submit" value="Login"></button></div>
</fieldset>
</form>
The login.php
内容:
<?php
// Include the launcher file.
require_once('globals.php');
require_once(CORE . 'launcher.php');
// Collect the information sent to us.
$mail = (isset($_POST['email'])) ? $_POST['email'] : '';
$password = (isset($_POST['password'])) ? $_POST['password'] : '';
$LoginError = false;
// AUTHORIZATION STUFF HERE
if ($LoginError) {
header('Status: 200');
header('X-Test: test');
header('Location: index.php');
exit();
}
如您所见,我将自定义标头发送到包含表单的脚本,以防登录期间出现错误。index.php
, 我在用着headers_list()
,但我发送的标头不存在于列表中。
是什么原因造成的?我尝试过php_value "output_buffering" "0"
in the .htaccess
文件,但没有成功。
UPDATE在 Chrome 中检查后,浏览器正在接收标头,但在 PHP 中不可用。
提前致谢。
重定向被发送到客户端并由客户端处理,客户端通过导航到给定的地址进行响应Location: index.php
。您不应期望浏览器在请求时提供自定义标头index.php
从服务器。
CLIENT SERVER
|------- POST login.php ------------------>|
| |
|<- 200, Location: index.php, X-Test:test -| (this is where you send the header)
| |
|------- GET index.php ------------------->| (no header from client to server)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)