后参考URL重定向我有下面的PHP代码:登录
<?php
// let's add a ref url feature for quick guidance.
$ref = $_SERVER['HTTP_REFERER'];
$actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]?ref=$ref";
header("Location: $actual_link");
if (empty($ref)) {
# do nothing...
} else {
$redirect_to_ref = header("Location: $ref");
header("Location: test.php");
}
}
?>
<?php
function checkRef() {
if (isset($redirect_to_ref)) {
$redirect_to_ref;
} else {
header("Location: index.php");
}
}
$error = false;
if(isset($_POST['login'])){
$username = htmlspecialchars($_POST['username']);
$password = md5($_POST['password']);
if(file_exists('users/' . $username . '.xml')){
$xml = new SimpleXMLElement('users/' . $username . '.xml', 0, true);
if($password == $xml->password){
session_start();
$_SESSION['username'] = $username;
checkRef();
die;
}
}
$error = true;
}
?>
此代码是一个简单的XML登录脚本。这将只记录该人,如果该人来自需要登录的人,但其中一人不是,我希望它在url栏中添加引用者,并且在登录成功后,重定向用户到该引用的网址。然而,这是现在给我一个500错误请帮...
使用'header(“Location:$ ref”);'?你测试登录是否成功? –
目前他们是否被重定向? –
目前,他们将被重定向,成功登录后,引用网址 – anonymous