在同一页面上使用带有$ _GET方法的引导程序表单

时间:2015-08-01 17:56:11

标签: php html forms twitter-bootstrap get

我无法让我的表单代码工作,我希望它在提交时更改当前页面网址,例如:weaw.com?id = Summitedtext,我会从php回复它。

        $cmd = 'htmlspecialchars($_SERVER["PHP_SELF"])'
        echo '<form id="idform" action="' . $cmd . '" method="GET">';
        echo '<label><center>To search an inventory please put the users Profile URL in the input box below.</center></label>';
        echo '<div class="input-group">';
        echo '<span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></span>';
        echo '<input type="text" class="form-control" placeholder="Profile URL" aria-describedby="basic-addon1">';
        echo '<span class="input-group-btn">';
        echo '<button class="btn btn-default" type="submit" name="submit" value="Submit">Go!</button>';
        echo '</span>';
        echo '</form>';
        echo '</div>';

1 个答案:

答案 0 :(得分:0)

完全不同意回音形式,但将代码更改为此并添加您的成分等课程等等:

<?PHP
if(isset($_GET['url'])
    $cmd = htmlspecialchars($_GET['url']);
else
    $cmd = htmlspecialchars($_SERVER["PHP_SELF"]);
?>
<form id="idform" action="<?PHP echo $cmd; ?>" method="GET">
    <input type="text" name="url">
    <input class="btn btn-default" type="submit" name="submit" value="Go!" />
</form>