“不能POST”php

时间:2016-11-30 14:53:57

标签: php node.js database server pug

我显然已经看到了与此事有关的其他线程,无法解决我的问题。我没有经验的PHP。我的文件结构如下:

 -search/
    -index.jade
    -search.php
    css/
      index.css

我的index.jade代码:

    html
    head
      script(src='https://code.jquery.com/jquery-3.1.0.min.js')
      link(href="css/index.css", rel="stylesheet", type="text/css")

    body 

      form(id="search", method="POST", action="search.php")
        input(type="text",placeholder="Search for...",name="search_bar")
        input(type="submit",name="submit") 

我的search.php代码:

<?php

$SQL_HOST = "peanuts";
$SQL_PSWD = "more_peanuts";
$SQL_USER = "peanuts_again";
$SQL_DB = "no_peanuts";

// jk...

try {
$link = new mysqli($SQL_HOST, $SQL_USER, $SQL_PSWD, $SQL_DB);  
} catch (Exception $e) {
echo "PDO connection error: " . $e->getMessage();
exit(1);
}

$search = $_POST['search_bar']."*";

$search_query = $link->prepare("SELECT name FROM products WHERE MATCH(name) AGAINST (? IN BOOLEAN MODE)");
$search_query->bind_param('s', $search);
$search_query->execute();
$search_query->store_result();
$search_rows = $search_query->num_rows;
$search_query->bind_result($product_name);

if($search_rows > 0) {

while($search_query->fetch()) {

echo "Your search returned $search_rows results";
echo "$product_name <br>";

}

} 

else {

    echo "Your search returned no results, sorry :(";

}   

?>

我一直得到:“不能POST /search/search.php”。帮助

0 个答案:

没有答案