Initial commit
This commit is contained in:
44
20241208/search_73.php
Normal file
44
20241208/search_73.php
Normal file
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>姓名查询</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form method="POST" action="search_73.php">
|
||||
<label for="search_name">姓名查询:</label>
|
||||
<input type="text" id="search_name" name="search_name" required>
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
include_once 'db_config.php';
|
||||
// 检查表单是否提交
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['search_name'])) {
|
||||
// 获取表单输入的姓名
|
||||
$searchName = $_POST['search_name'];
|
||||
// 设置字符集
|
||||
mysqli_set_charset($link, "utf8");
|
||||
|
||||
// 准备查询语句,使用准备语句以防SQL注入
|
||||
$query = $link->prepare("SELECT address FROM user_70 WHERE name = ?");
|
||||
$query->bind_param("s", $searchName);
|
||||
$query->execute();
|
||||
$result = $query->get_result();
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
// 输出查询结果
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo "<p>地址: " . htmlspecialchars($row['address']) . "</p>";
|
||||
}
|
||||
} else {
|
||||
// 在没有查询到结果时显示
|
||||
echo "<p>查无此人</p>";
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user