ok
Direktori : /home2/selectio/www/wedding-info-new/api/ |
Current File : /home2/selectio/www/wedding-info-new/api/deactive.php |
<?php include_once 'config/config.php'; // Assuming this file contains database connection details session_start(); error_log('Script started...'); if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_SESSION['user']['id'])) { // Sanitize and validate input data $startDateTime = $_POST['startDateTime']; $endDateTime = $_POST['endDateTime']; $uid = $_SESSION['user']['id']; try { // Prepare SQL statement $deactivateUsersSql = $pdo->prepare("UPDATE tbl_alliances_register SET status = 2, start_time = ?, end_time = ? WHERE id = ?"); // Bind parameters $deactivateUsersSql->bindParam(1, $startDateTime); $deactivateUsersSql->bindParam(2, $endDateTime); $deactivateUsersSql->bindParam(3, $uid); // Execute the statement $deactivateUsersSql->execute(); echo json_encode(["success" => true, "message" => "User accounts deactivated successfully"]); } catch (PDOException $e) { echo json_encode(["success" => false, "message" => "Error deactivating users: " . $e->getMessage()]); } finally { // Close the connection $pdo = null; } } else { // Handle invalid request or session data echo json_encode(["success" => false, "message" => "Invalid request"]); } ?>