使用PHP使用用户输入填充URL字段

时间:2013-01-10 15:30:15

标签: php html

我正在寻找一个简单的快速解决方案,使用PHP从基本HTML菜单(用户选择)填充URL字段。

例如: www.123.com/test.php?choice_1=USER_Input**t&choice_2 = ** USER_INPUT

所以我希望用户选择填充这2个粗体字段,然后请求它。它是我被要求在工作中做的事情,我没有访问数据库的权限。我只能申请一个网页。

4 个答案:

答案 0 :(得分:0)

urlencode数据。

$url = "http://example.com/test.php?choice_1=" . urlencode($input1) . "&choice_2=" . urlencode($input2)

答案 1 :(得分:0)

快速指南:

<form action="index.php" method="get">
<input type="text" name="input1" id="input1"/>
<input type="text" name="input2" id="input2"/>
<input type="submit" value="Submit">
</form>

网址如下所示:index.php?input1=VALUE&input2=VALUE

答案 2 :(得分:0)

描述这个HTML菜单,它是一个javascript或带有链接的纯HTML菜单吗? javascript菜单更灵活,可让您选择多个选项。我个人只会使用HTML表单并发布它。然后就可以了

header('Location: http://www.example.com/test.php?choice1=' . $POST['one'] . '&choice2=' . $POST['two']);

答案 3 :(得分:0)

$url = 'http://123.com/test.php?';
$parts = array();
$request = array(
    'input_1' => $_POST['input_1'],
    'input_2' => $_POST['input_2'],
    'input_3' => $_POST['input_3'],
);
foreach ($request as $key => $value) {
    $parts[] = "{$key}={$value}";
}
$url .= implode('&', $parts);