<?php
include('connection.php');
// Check if the edit form is submitted
if (isset($_POST['update'])) {
    $name = $_POST['name'];
    $id = $_POST['id'];
    $url = $_POST['url'];
    $number = $_POST['number'];

    // Update the contact's information in the database
    $updateSql = "UPDATE skype SET name = '$name', url = '$url', number = '$number' WHERE id = $id";
    $updateResult = mysqli_query($conn, $updateSql);

    if ($updateResult) {
        // Redirect back to the page with a success message
        header("Location: skype-add.php?success=Skype updated successfully.");
        exit();
    } else {
        // Redirect back to the page with an error message if the update fails
        header("Location: skype-add.php?error=Failed to update Skype.");
        exit();
    }
}
?>