-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
83 lines (82 loc) · 2.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>查询 IP 归属地</title>
<!-- Bootstrap CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Icons CSS -->
<link href="icons/bootstrap-icons.css" rel="stylesheet">
<!-- Bootstrap JS -->
<script src="js/bootstrap.min.js"></script>
<style>
body {
background-color: #f4f4f8;
font-family: 'Poppins', sans-serif;
}
.content-top-center {
min-height: 50vh;
}
.form-label {
font-weight: 600;
}
#ipQueryForm {
max-width: 400px;
margin: 0 auto;
}
h2 {
font-weight: 500;
color: #333;
}
#result {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
display: none;
}
</style>
</head>
<body class="d-flex flex-column justify-content-center text-center content-top-center">
<h2><i class="bi bi-search"></i> 请输入 IP 地址查询归属地:</h2>
<form id="ipQueryForm" class="mt-3">
<div class="mb-3">
<label for="ip_address" class="form-label">IP 地址:</label>
<div class="input-group">
<input type="text" name="ip_address" id="ip_address" class="form-control" style="margin-right: 5px;">
<button type="submit" class="btn btn-primary"><i class="bi bi-arrow-right-circle-fill"></i> 查询</button>
</div>
</div>
</form>
<div id="result" class="mt-4"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('ipQueryForm').addEventListener('submit', function(e) {
e.preventDefault();
let ip = document.querySelector("input[name='ip_address']").value;
fetch('ip_query.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'ip_address=' + ip,
})
.then(response => response.json())
.then(data => {
let resultDiv = document.getElementById('result');
resultDiv.style.display = 'block';
if (data.status === 'success') {
resultDiv.innerHTML = `<p class="text-success"><i class="bi bi-check-circle-fill"></i> ${data.message}</p>`;
} else if (data.status === 'error') {
resultDiv.innerHTML = `<p class="text-danger"><i class="bi bi-x-circle-fill"></i> ${data.message}</p>`;
} else {
resultDiv.innerHTML = `<p class="text-warning"><i class="bi bi-exclamation-circle-fill"></i> ${data.message}</p>`;
}
})
.catch(error => console.error('Error:', error));
});
});
</script>
</body>
</html>