php搜索框点击搜索后无法跳转页面,求帮忙看看代码
我想做一个搜索框,搜索关键字后在数据库中能匹配到它的网页链接,调出它的网页链接后不能跳转,以下是搜索框代码:<formmethod="get"id="searchform...
我想做一个搜索框,搜索关键字后在数据库中能匹配到它的网页链接,调出它的网页链接后不能跳转,以下是搜索框代码:
<form method="get" id="searchform" action="searchaction">
<fieldset class="search">
<input type="text" class="box" name="s" id="s" class="inputText" placeholder="php" x-webkit-speech>
<button class="btn" title="SEARCH" value="搜索"> </button>
</fieldset>
</form>
<html>
<head>
<title>logincheck</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<?php
$title=$_GET['s'];
$link=mysqli_connect('localhost','root','123456789','news');
if(!$link) die('Connect Error:'.mysqli_connect_error());
$sql="select address from search where title = '{$title}' ;";
var_dump($sql);
$result = mysqli_query($link,$sql);
if(!$result) die('Query Error:'.$SQL);
$num = mysqli_num_rows($result);
if($num){
$row = mysqli_fetch_array($result,MYAQLI_ASSOC);
echo "<script language='javascript'>";
echo "location='$address';";
echo "</script>";
}else{
echo" <script>alert('没有搜索到您需要的内容');history.go(-1);</script>";
}
?>
</html>
以下是数据库代码:
create table search(
title varchar(255) not null primary key,
address varchar(255)
); 展开
<form method="get" id="searchform" action="searchaction">
<fieldset class="search">
<input type="text" class="box" name="s" id="s" class="inputText" placeholder="php" x-webkit-speech>
<button class="btn" title="SEARCH" value="搜索"> </button>
</fieldset>
</form>
<html>
<head>
<title>logincheck</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<?php
$title=$_GET['s'];
$link=mysqli_connect('localhost','root','123456789','news');
if(!$link) die('Connect Error:'.mysqli_connect_error());
$sql="select address from search where title = '{$title}' ;";
var_dump($sql);
$result = mysqli_query($link,$sql);
if(!$result) die('Query Error:'.$SQL);
$num = mysqli_num_rows($result);
if($num){
$row = mysqli_fetch_array($result,MYAQLI_ASSOC);
echo "<script language='javascript'>";
echo "location='$address';";
echo "</script>";
}else{
echo" <script>alert('没有搜索到您需要的内容');history.go(-1);</script>";
}
?>
</html>
以下是数据库代码:
create table search(
title varchar(255) not null primary key,
address varchar(255)
); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询