0
有人可以幫助我將文本用戶輸入到搜索表單中的文字插入到url中嗎?如何在url中添加搜索值
例如: 如果用戶搜索 「行走deads」 它看起來像這樣:
www.domain.com/search.php?=the+walking+deads/
這是我的代碼:
<?php
function connect($host,$username,$database,$password){
$to_connect = mysql_connect($host,$username,$password) or die ("UNFinded ".$username. " DB !");
$db = mysql_select_db($database, $to_connect) or die (mysql_error());
return $db;
}
connect("localhost","idevice2_ariel","idevice2_ariel","ariel123456");
if (!isset($_POST['submit_form'])) {
echo '<form name="search_form1" id="form" method="POST" action="search.php">
<input type="text" style="width: 300px; display: block; margin: 0 auto; height: 36px; text-align: center; font-size: 16px;" name="search_name" placeholder="חפש סרט או סדרה..." />
<input type="submit" value="Submit" name="submit_form" />
</form>';
} else {
$search_name = $_POST['search_name'];
$query = mysql_query("SELECT * FROM `members` WHERE (`moviename` like '%".$search_name."%')");
$count = mysql_num_rows($query);
while($row = mysql_fetch_array($query)) {
$fname = $row['moviename'];
$lname = $row['links'];
print '<a href="'.$row['links'].'">'.$row['moviename'].'</a><br />';
}
}
mysql_close($to_connect);
?>
<html>
<head>
<style type="text/css">
a {
padding:25px 560px;
color: red;
}
</style>
</head>
<body>
</body>
</html>
$ SEARCH_NAME在搜索輸入要進入的用戶。 現在url仍然只有搜索文件名.. 謝謝!
阿斯克爾可能想看看http://php.net/manual/en/mysqli.quickstart.prepared-statements.php – StephenTG