* Date: 2026-6-1 */ $error = ''; $success = ''; if($_SERVER['REQUEST_METHOD'] === 'POST') { $name = isset($_POST['name']) ? trim($_POST['name']) : ''; $phone = isset($_POST['phone']) ? trim($_POST['phone']) : ''; $title = isset($_POST['title']) ? trim($_POST['title']) : ''; $content = isset($_POST['content']) ? trim($_POST['content']) : ''; if(empty($name) || empty($phone) || empty($title) || empty($content)) { $error = '请填写完整信息'; } else { $ip = $_SERVER['REMOTE_ADDR'] ?? ''; $last = $db->fetch("SELECT id FROM {$db->table('guestbook')} WHERE ip = ? AND create_time > DATE_SUB(NOW(), INTERVAL 60 SECOND)", [$ip]); if($last) { $error = '请勿重复提交,请稍后再试'; } else { $db->query("INSERT INTO {$db->table('guestbook')} (channel_id, name, phone, title, content, ip, create_time, is_show) VALUES (?, ?, ?, ?, ?, ?, ?, 0)", [ 8, $name, $phone, $title, $content, $ip, date('Y-m-d H:i:s') ]); $success = '提交成功,我们会尽快与您联系!'; } } } $guestbooks = $db->fetchAll("SELECT * FROM {$db->table('guestbook')} WHERE is_show = 1 ORDER BY create_time DESC LIMIT 20"); ?>
暂无留言