Файловый менеджер - Редактировать - /home/gqdcvggs/.trash/respond_event.php
Назад
<?php header('Content-Type: application/json'); header('Access-Control-Allow-Origin: *'); require_once 'config.php'; $conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); if ($conn->connect_error) { echo json_encode(['success' => false, 'error' => 'Database connection failed']); exit; } $data = json_decode(file_get_contents('php://input'), true); $eventId = intval($data['eventId']); $userId = intval($data['userId']); $status = $conn->real_escape_string($data['status']); $checkSql = "SELECT id FROM event_participants WHERE event_id = $eventId AND user_id = $userId"; $checkResult = $conn->query($checkSql); if ($checkResult->num_rows > 0) { $sql = "UPDATE event_participants SET status = '$status' WHERE event_id = $eventId AND user_id = $userId"; } else { $sql = "INSERT INTO event_participants (event_id, user_id, status) VALUES ($eventId, $userId, '$status')"; } if ($conn->query($sql) === TRUE) { echo json_encode(['success' => true]); } else { echo json_encode(['success' => false, 'error' => $conn->error]); } $conn->close(); ?>
| ver. 1.6 |
Github
|
.
| PHP 8.1.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка