【发布时间】:2014-06-06 23:30:14
【问题描述】:
我在格式化我的代码时一定有问题,但找不到在哪里, 这是我放置搜索栏的形式:
<form>
<?php include_once("searchbar.php"); ?>
</form>
这是我的搜索条形码:
<form method= "post" action = "search.php">
<input type="text" name="search_input" placeholder="Search Designer Sofas..." />
<input type="submit" value="Search" />
</form>
这是搜索结果页面的开始
<!DOCTYPE html>
<?php
//retrieves the specified element from the URL
$search_input = $_POST["search_input"];
include_once("connection_to_db.php");
//isset function checks if a variable is set
if(!isset($search_input))
{
print("Nothing to search !");
return;
}
//take the books with the specific name
$query_products = "SELECT * FROM XXX WHERE name LIKE '%".$search_input."%'";
$query_product_result = mysql_query($query_products)
or die(mysql_error());
$num_rows_products = mysql_num_rows($query_product_result);
?>
<html lang="en">
<head>
现在发生的情况是,当我单击搜索按钮时,搜索查询的 url 中的地址发生了变化,但页面没有,这是否意味着它正在发送给它但没有收到任何东西?
【问题讨论】:
-
您应该使用 mysqli 或 PDO 以及准备好的语句,否则 Bobby Tables 会破坏您的数据库。