【发布时间】:2023-04-05 07:47:01
【问题描述】:
我正在编写一个基本的授权系统,但我有点挣扎。涉及两个文件 - index.php 和 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>
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(),但标头我'列表中不存在 m 发送。
是什么原因造成的?我尝试在.htaccess 文件中使用php_value "output_buffering" "0",但没有成功。
更新 在 Chrome 中检查后,浏览器正在接收标头,但在 PHP 中不可用。
提前致谢。
【问题讨论】:
-
答案现在应该很清楚了,有四种不同的解释:D
标签: php .htaccess redirect http-headers