我在这里找到了几个例子。这就是我的代码所在。但它缺少一件。我需要在URL字符串的末尾添加“& next = http://facebook.com”,以便最终结果为:
https://www.facebook.com/dialog/pagetab?app_id=########&next=http://facebook.com
(######## =输入数据)
到目前为止,这就是我所拥有的:
< ?PHP if(isset($ _ POST ['bt'])) { 标题(“位置:https://www.facebook.com/dialog/pagetab?app_id=”。$ _POST ['folder']); }
>
< HTML>
< form id =“form1”name =“form1”method =“post”action =“”>
< input type="text" name="folder" id="folder" /> < input type="submit" name="bt" id="bt" value="Go To" />
&LT; /形式&GT; &LT; / HTML&GT;
答案 0 :(得分:1)
<?php
if (isset($_POST['bt'])) {
$newLocation = "https://www.facebook.com/dialog/pagetab?app_id=".$_POST['folder'];
$newLocation .= "&next=http://facebook.com";
header("Location: " . $newLocation);
}
?>
您也可以在一行中连接它们(如下所示)。就个人而言,我喜欢像上面那样分解它,但是 - 这完全取决于程序员。
$newLocation = "https://www.facebook.com/dialog/pagetab?app_id=".$_POST['folder'] . "&next=http://facebook.com";
答案 1 :(得分:0)
尝试
<?php
if (isset($_POST['bt'])) {
$newLocation = 'https://www.facebook.com/dialog/pagetab?' .
http_build_query(array('app_id' => $_POST['folder'], 'next' => 'http://facebook.com'));
header("Location: " . $newLocation);
}