如何摆脱HTML / PHP中的确认表单重新提交?

时间:2017-11-26 11:45:05

标签: php html css html5

这是我的搜索表单的HTML代码,用于输入。

<div class="srcarea">
<form action="result_page.php" method="post">
    <input type="text" name="search" class="search" placeholder="What's On Your Mind Today?"></br>
    <input type="submit" name="" value="Go" class="srcbtn"> 
</form>
</div>

这是PHP代码在数据库中搜索结果。

<?php

include 'connection.php';
$result ='';
$count='';
// Create connection
//$conn = mysqli_connect($servername, $username, $password);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
//echo "Connected successfully";
mysqli_select_db($conn,"search") or die ("Could Not find the db");
$output = "";

if(isset($_POST['search'])) {

    #$searchq = $_POST['search'];
    $searchq = mysqli_real_escape_string($conn,$_POST['search']);
    if($searchq !="")
    {
    $result=$query = mysqli_query($conn,"SELECT * FROM members WHERE firstname LIKE '%$searchq%' OR lastname LIKE '%$searchq%'");
    }
    if($result){
         $count =mysqli_num_rows($query);
    }

    if($count ==0)
    {
        $output = 'No Results Found !';
    }
    else
    {
        while($row = mysqli_fetch_array($query)){
            $fname = $row['firstname'];
            $lname = $row['lastname'];
            $id = $row['id'];
            $output .='<div>'.$fname.' '.$lname.'</div>';

        }

    }

}
//echo ($output);
?>

我正在显示此页面上的搜索输出,我确认重新提交对话我已经在这里寻找可能的解决方案,但我无法解决此问题。

<div class="header">
<?php
include 'header.php';
?>

</div>
<div id="res">
<?php
include 'search.php';
?>
<?php print("output")?>
</div>

我需要解决这个问题。

0 个答案:

没有答案