Reputation: 1124
I have a form in a navigation bar. When I type something and click enter, I just obtain the page of this URL /html/sphider/search.php and not /html/sphider/search.php?query=something&search=1 as normally I should have.
<form class="navbar-form navbar-right" action="/html/sphider/search.php" method="POST">
<input type="text" name="query" class="form-control" placeholder="Search...">
<input type="image" src="../images/search.png" name="btn" alt="search">
<input type="hidden" name="search" value="1">
</form>
Does anyone know why the parameters are not passed correctly to the search page?
Upvotes: 0
Views: 77
Reputation: 181
Your action tells your form to post all data to "/html/sphider/search.php" path.
And within this script, you should reach your $_POST data. Like $_POST['name']
See more about PHP Requests from this article
Upvotes: 1
Reputation: 962
You are using POST. For Post url will not include query value. Use Get insted POST. If you want to use POST then try this.
$_POST["search"];
This will be value of search
Upvotes: 3
Reputation: 1681
You are sending a POST request, not a GET request. POST sends the data transparently through, while GET sends the data using the URL as you noted in your question. Set method="get"
<form class="navbar-form navbar-right" action="/html/sphider/search.php" method="GET">
Upvotes: 3