PHP-标头不继承当前URL的先前部分

时间:2018-10-04 12:06:19

标签: php

if(isset($_POST['submit']))
{
    $hash = $_GET['hash'];
    $email = $_GET['email'];
    //method 1
        //echo "<script>document.location.href=resetpass.php?email=".$email."&hash=".$hash"</script>";
    //method 2
        header("Location: http://www.mywebsite.com/resetpass.php?email=".$email."&hash=".$hash");
        exit;
}

为什么在这种情况下我尝试做不到的任何事情?哈希和电子邮件最初位于URL内,但是一旦我更改URL,它就不会继续存在。我不明白这一点,因为它应该能够在创建URL之前抓取它并存储变量。为什么有某种原因?我已经在堆栈交换上寻找有关此问题的答案,但是我没有看到针对此问题的任何答案。

这是表单初始化,可能在这里有问题吗?

<!DOCTYPE html>
<html>
<body>
<meta content="noindex, nofollow" name="robots">
<form action="resetpass.php" id="#form" method="post" name="#form">

2 个答案:

答案 0 :(得分:0)

请尝试以下代码

header("Location: http://www.mywebsite.com/resetpass.php?email=$email&hash=$hash");
    exit;

已通过测试。

答案 1 :(得分:-1)

应该是这样

 header("Location: http://www.mywebsite.com/resetpass.php?email='$email'&hash='$hash'");
相关问题