I have an HTML form that is queried with PHP to search for animals: animals.php
與HTML <a href...>
Everything works great however I was wondering if I can also access the form with an HTML anchor tag. So when you click:
<a href="">giraffe</a>
it will query the DB for a giraffe through animals.php
.
<form method="post" action="s.php?go" id="searchform">
<input class="search" type="text" name="heyworld">
<input class="button" type="submit" name="submit" value="Search">
</form>
My PHP query works like this:
if(isset($_POST['submit']) && isset($_GET['go']) && preg_match("/^[ a-zA-Z0-9#@]+/", $_POST['msg'])){
//query the db
//echo the results
你可以訪問它有一個href =「animals.php?go = giraffe」>長頸鹿? – uneducatedguy 2013-04-27 07:43:46
不,不幸的是,我相信它在這種情況下不起作用 – user1775570 2013-04-27 07:44:35
它會工作,如果你讓PHP腳本通過GET而不是POST接受所有數據(這會使它比我在下面發佈的答案更簡單) – 2013-04-27 07:49:46