<?php

use FontLib\Table\Type\head;

include('connection.php');

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $platformId = $_POST["id"];
    $newPlatform = $_POST["service"];

 
    $platformId = intval($platformId); 
    $newPlatform = htmlspecialchars($newPlatform);

   
    $checkSql = "SELECT id FROM add_service WHERE id = $platformId";
    $checkResult = mysqli_query($conn, $checkSql);

    if (mysqli_num_rows($checkResult) > 0) {
     
        $updateSql = "UPDATE add_service SET name = '$newPlatform' WHERE id = $platformId";

        if (mysqli_query($conn, $updateSql)) {

            // echo "Platform updated successfully!";
            header("Location:add_service.php");

        } else {
            echo "Error updating platform: " . mysqli_error($conn);
        }
    } else {
        echo "Platform not found.";
    }

    // Close the database connection
    mysqli_close($conn);
}
?>
