37666-vm/join_community.php
Flatlogic Bot f8ac1e502b 1.0
2026-01-21 14:14:15 +00:00

29 lines
885 B
PHP

<?php
header('Content-Type: application/json');
require_once 'db/config.php';
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
echo json_encode(['success' => false, 'error' => 'Invalid method']);
exit;
}
$name = trim($_POST['name'] ?? '');
$location = trim($_POST['location'] ?? '');
$favorite_team = trim($_POST['favorite_team'] ?? '');
$bio = trim($_POST['bio'] ?? '');
if (empty($name) || empty($location)) {
echo json_encode(['success' => false, 'error' => 'Name and Location are required']);
exit;
}
try {
$pdo = db();
$stmt = $pdo->prepare("INSERT INTO members (name, location, favorite_team, bio) VALUES (?, ?, ?, ?)");
$stmt->execute([$name, $location, $favorite_team, $bio]);
echo json_encode(['success' => true]);
} catch (PDOException $e) {
echo json_encode(['success' => false, 'error' => 'Database error: ' . $e->getMessage()]);
}