【问题标题】:Passing URL query Variable to different Forms将 URL 查询变量传递给不同的表单
【发布时间】:2015-11-28 02:44:27
【问题描述】:

我需要将用户从一个 php 表单发送到另一个表单,但我也需要传递一个 URL 查询。所以他们到达example.com/Form1.php$email=Whatever@Whatever.com,然后他们需要传递给example.com/Form2.php$email=Whatever@whatever.com。我无法让它在标题周围的 '' 中使用 $_GET('Location: http://www.example.com');

查看代码


<?php

$email = $_GET["email"];

$_POST['customerSatisfaction'];
    $to = "blah";
    $email_from = 'blah';
    $email_subject = "blah";
    $headers = "From: $email_from \r\n";
    $email_body =   "   <?xml version = \"1.0\"?>
    <?adf version = \"1.0\"?>
        <adf>

            <prospect>
                <customer>

                <email preferredcontact=\"1\">$email</email>

                </customer>

            </prospect>
        </adf>
";
    mail($to,$email_subject,$email_body,$headers);
    header('Location: http://www.BLAH.com/NEED $EMAIL HERE!!');
?>

【问题讨论】:

    标签: php get


    【解决方案1】:

    您发布的内容无效。试试这个:

    header('Location: http://www.BLAH.com/?email=' . urlencode($email));

    另外,在发送重定向标头后添加exit; 通常是个好主意。

    【讨论】:

    • 如何避免收到 ?email=Blah%40Gmail.com?我无法在接收端解析。
    • @ 已被编码,因为它是一个特殊字符。 $_GET 会自动解码,你不需要做任何事情。
    • 但另一方面它不是,解析正在使用 %40 删除它。我知道你使用 urldecode 和 $_GET 但我不知道在哪里。
    • $_GET 自动通过 urldecode 传递变量。不要手动操作,正如我所说的,您无需执行任何操作!请参阅此处的警告php.net/manual/en/function.urldecode.php
    猜你喜欢
    • 2017-01-06
    • 2015-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-16
    相关资源
    最近更新 更多