有人可以帮我将用户在搜索表单中输入的文本插入 url 吗?
例如:如果用户搜索“行尸走肉”,它将如下所示:
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 仍然只有搜索文件名.. 谢谢!