求大神帮忙小童鞋,初学者遇到问题求帮忙解决

qqpp_4477 2018-01-12 11:28:00
用DW5编辑网页搜索页面时,预览中出现如下代码:
Notice: Undefined index: textfield in P:\leyou\search.php on line 224

具体页面截图如下:



具体代码如下(附代码截图):
<?php require_once('Connections/gongsi.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$maxRows_Rs_search = 10;
$pageNum_Rs_search = 0;
if (isset($_GET['pageNum_Rs_search'])) {
$pageNum_Rs_search = $_GET['pageNum_Rs_search'];
}
$startRow_Rs_search = $pageNum_Rs_search * $maxRows_Rs_search;

$colname_Rs_search = "-1";
if (isset($_POST['textfield'])) {
$colname_Rs_search = $_POST['textfield'];
}
mysql_select_db($database_gongsi, $gongsi);
$query_Rs_search = sprintf("SELECT * FROM xinwen WHERE biaoti LIKE %s", GetSQLValueString("%" . $colname_Rs_search . "%", "text"));
$query_limit_Rs_search = sprintf("%s LIMIT %d, %d", $query_Rs_search, $startRow_Rs_search, $maxRows_Rs_search);
$Rs_search = mysql_query($query_limit_Rs_search, $gongsi) or die(mysql_error());
$row_Rs_search = mysql_fetch_assoc($Rs_search);

if (isset($_GET['totalRows_Rs_search'])) {
$totalRows_Rs_search = $_GET['totalRows_Rs_search'];
} else {
$all_Rs_search = mysql_query($query_Rs_search);
$totalRows_Rs_search = mysql_num_rows($all_Rs_search);
}
$totalPages_Rs_search = ceil($totalRows_Rs_search/$maxRows_Rs_search)-1;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/muban.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>搜索页</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<style type="text/css">
body,td,th {
font-family: "宋体";
font-size: 14px;
color: #333;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a {
font-family: "宋体";
font-size: 14px;
color: #333;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #333;
}
a:hover {
text-decoration: none;
color: #F00;
}
a:active {
text-decoration: none;
color: #F00;
}
.Daohang {
font-family: "宋体";
font-size: 16px;
font-style: normal;
font-weight: bold;
color: #FFF;
text-decoration: none;
}
.Biaoti {
font-family: "宋体";
font-size: 14px;
font-weight: bold;
color: #F00;
}
.BiaotiK {
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: none;
border-right-style: none;
border-bottom-style: solid;
border-left-style: none;
border-top-color: #CCC;
border-right-color: #CCC;
border-bottom-color: #CCC;
border-left-color: #CCC;
}
.UxingK {
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
border-top-style: none;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
border-top-color: #CCC;
border-right-color: #CCC;
border-bottom-color: #CCC;
border-left-color: #CCC;
}
.SsbeijingK {
background-image: url(../images/sskuang.png);
}
.SswenbenK {
border:0px none #FFF;
height:30px;
width:340px;
font-size:24px;
outline:none;
}
Daohang a:link {
font-family: "宋体";
font-size: 16px;
font-weight: bold;
color: #FFF;
text-decoration: none;
}
Daohang a:visited {
font-family: "宋体";
font-size: 16px;
color: #FFF;
text-decoration: none;
}
</style>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="32" class="BiaotiK"><table width="980" border="0" align="center" cellpadding="0" cellspacing="0" class="BiaotiK">
<tr>
<td width="111" height="25">欢迎访问本网站</td>
<td width="98" height="25">
<?php
if(!isset($_SESSION)){session_start();}
if(isset($_SESSION["zhanghao"])){echo $_SESSION['zhanghao'];}
?>
</td>
<td width="90" height="25"> </td>
<td width="90" height="25"> </td>
<td width="90" height="25"> </td>
<td width="90" height="25"> </td>
<td width="90" height="25"> </td>
<td width="90" height="25"> </td>
<td width="98" height="25">注册</td>
<td width="98" height="25">登入</td>
</tr>
</table>
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="326"><img src="logo/logo.png" alt="" width="326" height="129" /></td>
<td><form id="form1" name="form1" method="post" action="search.php">
<table width="470" border="0" align="center" cellpadding="0" cellspacing="0" class="SsbeijingK">
<tr>
<td width="370" height="45" align="right"><label for="search"></label>
<input name="search" value="<?php if(isset($_POST['textfield'])){echo $_POST['textfield'];} ?>" type="text" class="SswenbenK" id="search" width="370" height="45" /></td>
<td width="100" height="45"><input type="image" name="imageField" id="imageField" src="images/ssniu.png" /></td>
</tr>
</table>
</form></td>
</tr>
</table>
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0" class="Daohang">
<tr>
<td height="40" align="center" bgcolor="#4d5b66" class="Daohang">网站首页</td>
<td height="40" align="center" bgcolor="#4d5b66" class="Daohang">乐游动态</td>
<td height="40" align="center" bgcolor="#4d5b66" class="Daohang">景区景点</td>
<td height="40" align="center" bgcolor="#4d5b66" class="Daohang">旅游特产</td>
<td height="40" align="center" bgcolor="#4d5b66" class="Daohang">旅游服务</td>
<td height="40" align="center" bgcolor="#4d5b66" class="Daohang">乐游路线</td>
</tr>
</table>
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="logo/banner.gif" width="980" height="200" /></td>
</tr>
</table>
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><!-- InstanceBeginEditable name="EditRegion3" -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>搜索有关<?php echo $_POST['textfield']; ?>的内容是:
<?php if ($totalRows_Rs_search == 0) { // Show if recordset empty ?>
这里没有你要搜索的内容!
<?php } // Show if recordset empty ?></td>
</tr>
<tr>
<td><a href="nr.php?id=<?php echo $row_Rs_search['id']; ?>">
<?php do { ?>
<?php echo $row_Rs_search['biaoti']; ?>
<?php } while ($row_Rs_search = mysql_fetch_assoc($Rs_search)); ?>
</a></td>
</tr>
</table>
<!-- InstanceEndEditable --></td>
</tr>
</table>
<br />
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="100" align="center" valign="middle" bgcolor="#eeeeee"><p>乐游侨乡:乐游游乐悠悠!</p>
<hr width="98%" style="color:#f15a24; height:1px" />
<p>copyright©:乐游侨乡  版权所有!</p></td>
</tr>
</table>
<p> </p></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($Rs_search);
?>
...全文
954 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qqpp_4477 2018-01-22
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
你的表单中只有 <input name="search" ,并未名为 textfield 的控件,自然 $_POST['textfield'] 是不存在的
要怎么做?小白不懂
qqpp_4477 2018-01-22
  • 打赏
  • 举报
回复
引用 2 楼 redword 的回复:
textfield 没有初始化
怎么初始化啊,小白不懂
徐卡丘 2018-01-22
  • 打赏
  • 举报
回复
引用 5 楼 qqpp_4477 的回复:
[quote=引用 1 楼 xuzuning 的回复:] 你的表单中只有 <input name="search" ,并未名为 textfield 的控件,自然 $_POST['textfield'] 是不存在的
要怎么做?小白不懂[/quote] <input name="search" value="<?php if(isset($_POST['textfield'])){echo $_POST['textfield'];} ?>" type="text" class="SswenbenK" id="search" width="370" height="45" /> $_POST['value'] 这个‘value’ 得是<input name="search" .../>里的name属性的值, 要么把 $_POST['textfield'] 改成 $_POST['search'], 要么把input标签的 name="search" 改成 name="textfield"
  • 打赏
  • 举报
回复
没有定义 , ,
xuzuning 2018-01-12
  • 打赏
  • 举报
回复
你的表单中只有 <input name="search" ,并未名为 textfield 的控件,自然 $_POST['textfield'] 是不存在的
redword 2018-01-12
  • 打赏
  • 举报
回复
textfield 没有初始化

21,881

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧