Add k3s cluster expansion documentation and scripts
- Complete expansion guide for 2/4/6 node scenarios - Quick join scripts for worker and master nodes - Health check and diagnostic scripts - Quick reference card for common operations
This commit is contained in:
210
php-test/index.php
Normal file
210
php-test/index.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>PHP MySQL 测试表单</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 20px;
|
||||
}
|
||||
.container {
|
||||
background: white;
|
||||
padding: 40px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
|
||||
max-width: 500px;
|
||||
width: 100%;
|
||||
}
|
||||
h1 {
|
||||
color: #333;
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
color: #555;
|
||||
font-weight: 500;
|
||||
}
|
||||
input, textarea {
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 2px solid #e0e0e0;
|
||||
border-radius: 5px;
|
||||
font-size: 14px;
|
||||
transition: border-color 0.3s;
|
||||
}
|
||||
input:focus, textarea:focus {
|
||||
outline: none;
|
||||
border-color: #667eea;
|
||||
}
|
||||
textarea {
|
||||
resize: vertical;
|
||||
min-height: 100px;
|
||||
}
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
button:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
.message {
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 20px;
|
||||
display: none;
|
||||
}
|
||||
.message.success {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
border: 1px solid #c3e6cb;
|
||||
display: block;
|
||||
}
|
||||
.message.error {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
border: 1px solid #f5c6cb;
|
||||
display: block;
|
||||
}
|
||||
.records {
|
||||
margin-top: 30px;
|
||||
padding-top: 30px;
|
||||
border-top: 2px solid #e0e0e0;
|
||||
}
|
||||
.records h2 {
|
||||
color: #333;
|
||||
margin-bottom: 15px;
|
||||
font-size: 20px;
|
||||
}
|
||||
.record-item {
|
||||
background: #f8f9fa;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 10px;
|
||||
border-left: 4px solid #667eea;
|
||||
}
|
||||
.record-item strong {
|
||||
color: #667eea;
|
||||
}
|
||||
.record-item p {
|
||||
margin: 5px 0;
|
||||
color: #555;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>📝 数据库测试表单</h1>
|
||||
|
||||
<?php
|
||||
require_once 'Database.php';
|
||||
|
||||
// 显示提交结果消息
|
||||
if (isset($_GET['status'])) {
|
||||
if ($_GET['status'] === 'success') {
|
||||
echo '<div class="message success">✅ 数据提交成功!</div>';
|
||||
} elseif ($_GET['status'] === 'error') {
|
||||
$error = htmlspecialchars($_GET['msg'] ?? '未知错误');
|
||||
echo '<div class="message error">❌ 提交失败: ' . $error . '</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<form action="submit.php" method="POST">
|
||||
<div class="form-group">
|
||||
<label for="name">姓名 *</label>
|
||||
<input type="text" id="name" name="name" required placeholder="请输入您的姓名">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="email">邮箱 *</label>
|
||||
<input type="email" id="email" name="email" required placeholder="example@email.com">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="message">留言</label>
|
||||
<textarea id="message" name="message" placeholder="请输入您的留言..."></textarea>
|
||||
</div>
|
||||
|
||||
<button type="submit">提交数据</button>
|
||||
</form>
|
||||
|
||||
<div class="records">
|
||||
<h2>📊 最近提交的数据</h2>
|
||||
<?php
|
||||
try {
|
||||
$db = Database::getConnection();
|
||||
$stmt = $db->query("SELECT * FROM test_data ORDER BY created_at DESC LIMIT 5");
|
||||
$records = $stmt->fetchAll();
|
||||
|
||||
if (count($records) > 0) {
|
||||
foreach ($records as $record) {
|
||||
echo '<div class="record-item">';
|
||||
echo '<p><strong>姓名:</strong> ' . htmlspecialchars($record['name']) . '</p>';
|
||||
echo '<p><strong>邮箱:</strong> ' . htmlspecialchars($record['email']) . '</p>';
|
||||
if (!empty($record['message'])) {
|
||||
echo '<p><strong>留言:</strong> ' . htmlspecialchars($record['message']) . '</p>';
|
||||
}
|
||||
echo '<p><strong>提交时间:</strong> ' . $record['created_at'] . '</p>';
|
||||
echo '</div>';
|
||||
}
|
||||
} else {
|
||||
echo '<p style="color: #999; text-align: center;">暂无数据</p>';
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo '<p style="color: #dc3545;">数据库查询失败: ' . htmlspecialchars($e->getMessage()) . '</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 热更新脚本 -->
|
||||
<script>
|
||||
let lastModified = null;
|
||||
|
||||
function checkForUpdates() {
|
||||
fetch(window.location.href, {
|
||||
method: 'HEAD',
|
||||
cache: 'no-cache'
|
||||
})
|
||||
.then(response => {
|
||||
const modified = response.headers.get('Last-Modified');
|
||||
if (lastModified && modified && lastModified !== modified) {
|
||||
console.log('检测到文件更新,正在刷新页面...');
|
||||
window.location.reload();
|
||||
}
|
||||
lastModified = modified;
|
||||
})
|
||||
.catch(err => console.error('检查更新失败:', err));
|
||||
}
|
||||
|
||||
// 每2秒检查一次更新
|
||||
setInterval(checkForUpdates, 2000);
|
||||
checkForUpdates();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user