我正在编写一个基本的授权系统,我正在为此苦苦挣扎。有两个文件涉及 - index.php
和login.php
。登录表单是非常简单的(这里面index.php
): 带自定义头的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>
的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()
,但我要发送的标题不在列表中。
这是什么原因造成的?我试过.htaccess
文件中的php_value "output_buffering" "0"
,但没有成功。
UPDATE 在Chrome中签入之后,浏览器正在接收标头,但在PHP中不可用。
在此先感谢。
答案应该清楚,现在有四种不同的解释:D – 2012-04-10 18:58:48
请参阅更新。 – Pateman 2012-04-10 19:00:32