2015-05-24 73 views
0

的index.html代碼:打印搜索查詢

<form action="search.php" method="post" name="search"> 
    <input type="text" id="search_query" class="field" name="search_query" placeholder="Search a website ..."/>&nbsp; 
    <input type="submit" name="search" id="submit" value="Search"/> 

的search.php代碼:

<input type="text" id="go" class="field" name="go" value=""/>&nbsp; 
<input type="submit" name="search" id="submit" value="Search"/> 

我想從index.html頁面上的搜索文本預填充的search.php搜索框

還有一兩件事,我想要做的東西,所以人不能點擊搜索按鈕,如果在搜索一個網站...值

<form action="search.php" method="get" name="search"> 
    <input type="search" id="search_query" class="field" name="search_query" placeholder="Search a website ..."/>&nbsp; 
    <input type="submit" name="search" id="submit" value="Search"/> 
+0

php print?.... – Afsar

+0

你是否想要從索引頁ti搜索頁面預填充type =「text」id =「go」的輸入值 – Afsar

+0

您是否使用PDO或mysqli連接到您的數據庫查詢用戶輸入的文字結果 – Falt4rm

回答

0

當你處理與搜索引擎,最好使用GET方法,而不是使用POST,因爲你得到的數據,所以用得到您的搜索表單。

<form action="search.php" method="get" name="search"> 
<input type="text" id="search_query" class="field" name="search_query" placeholder="Search a website ..."/>&nbsp; 
<input type="submit" name="search" id="submit" value="Search"/> 

<input type="text" id="go" class="field" name="go" value=""/> 
    <?php if(isset($_GET['search_query'])) 
       echo $_GET['search_query'] ?> 
<input type="submit" name="search" id="submit" value="Search"/> 

而這一切都只是一個意見。

+0

還有一件事,我想做的事情,所以人們不能點擊搜索按鈕,如果有搜索網站...值\t \t \t

  Lucianss

0

如果你理解正確的問題,你想預先填寫輸入值與type =「text」從索引頁面到搜索頁面。

應該這樣做 - 的search.php代碼:

<input type="text" id="go" class="field" name="go" value=""/> 
    <?php if(isset($_POST['search_query'])) 
       echo $_POST['search_query'] ?> 
<input type="submit" name="search" id="submit" value="Search"/>