Php 如何在多个搜索选项中发送数据
大家好,我在我的站点的自定义页面中编写了一个搜索php,并希望在同一页面中执行搜索任务(我不希望将数据发送到操作页面)。 但我有问题,我不知道为什么这不起作用,请有人告诉我问题出在哪里,现在的问题是什么?! 多谢各位Php 如何在多个搜索选项中发送数据,php,Php,大家好,我在我的站点的自定义页面中编写了一个搜索php,并希望在同一页面中执行搜索任务(我不希望将数据发送到操作页面)。 但我有问题,我不知道为什么这不起作用,请有人告诉我问题出在哪里,现在的问题是什么?! 多谢各位 <div class="row-fluid"> <div class="page-header"> <h1>Search Users: </h1> </div>
<div class="row-fluid">
<div class="page-header">
<h1>Search Users: </h1>
</div>
<center>
<h2>Find user(s)</h2>
<form name="search" method="post" action="">
Seach for: <input type="text" name="find" /> with
<Select NAME="field">
<Option VALUE="user_id">User ID</option>
<Option VALUE="username">Username</option>
<Option VALUE="serialnumber">SerialNumber</option>
<Option VALUE="ip_address">IP Address</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" class="btn btn-success" style="vertical-align: super;" />
</form>
<span><?php echo $error; ?></span>
</center>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>E-mail</th>
<th>IP</th>
<th>serialnumber</th>
<th>Actions</th>
</tr>
</thead>
<?php
if (isset($_POST['submit'])) {
if (empty($_POST['find']) || empty($_POST['field'])) {
$error = "Pleas choice options";
}
else
{
$find=$_POST['find'];
$value=$_POST['field'];
$sql = "SELECT * FROM login_log WHERE '$value' = '$find'";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result)) {
?>
<tbody>
<tr class="pending-user">
<td><?php echo $row['user_id']; ?></td>
<td><?php echo $row['username']; ?></td>
<td><?php echo $row['email']; ?></td>
<td><?php echo $row['ip_address']; ?></td>
<td><?php echo $row['serialnumber']; ?></td>
<td><a href="ban.php?id=<?php echo $row['user_id']; ?>&ip=<?php echo $row['ip_address']; ?>&sn=<?php echo $row['serialnumber']; ?>" class="btn btn-primary">Ban User</a></td>
</tr>
</tbody>
<?php
}
}
}
?>
</table>
</div>
搜索用户:
查找用户
搜索:与
用户ID
用户名
序列号
IP地址
身份证件
名称
电子邮件
知识产权
序列号
行动
$\u POST
将包含表单中的元素,您在表单字段中使用了name=
属性$_除非其中一个字段或按钮具有name=“submit”
,否则POST['submit']将不存在。执行var_dump($_POST)以查看哪些值被发送回表单
将isset($\u POST['submit'])
更改为isset($\u POST['search'])
查看有关如何使用表单的a。I使用用户ID搜索“1”,结果是:数组(4){[“查找”]=>string(1)“1”[“字段”]=>string(7)“用户ID”[“搜索”]=>string(3)“是”[“提交”]=>string(6)“搜索”}是的,这些是表单元素(按钮、字段)您为其指定了
名称
属性。您没有使用name=“submit”
设置任何按钮或字段,因此$\u POST['submit']
将始终是未定义的,并且isset($\u POST['submit'])
将始终返回false
。添加了“确定”,但对isset($\u POST['submit'])
进行了相同的更改($\u POST('search')它将在'if'块中处理它后面的代码。致命错误:无法对函数调用的结果使用isset()(您可以改为使用“null!==func()”)