Files
luowei/search_73.php
2025-01-08 12:19:48 +08:00

42 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once "db_config.php"; // 引入数据库配置
$conn = $link;
// 判断是否有表单提交过来的数据
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$search_name = $_POST['search_name'];
// 编写SQL查询语句从user_70表中根据姓名查找对应的地址信息
$sql = "SELECT address FROM user_70 WHERE name = '$search_name'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// 如果查询到数据,输出对应的地址
while ($row = $result->fetch_assoc()) {
echo $row["address"];
}
} else {
// 如果没有查询到数据,输出提示信息
echo "查无此人";
}
}
// 关闭数据库连接
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>姓名查询</title>
</head>
<body>
<!-- 创建form表单用于输入姓名进行查询 -->
<form action="search_73.php" method="post">
<label for="search_name">姓名:</label>
<input type="text" id="search_name" name="search_name">
<input type="submit" id="ok" name="ok" value="确定">
</form>
</body>
</html>