<?php
include("../../includes/connect.php");
print_r($_POST);
echo "<hr />";

     echo "Modifico il set di redirect";
     $redirectSetId = $_POST['redirectSetId'];
    $redirectSetName = $_POST['redirectSetName'];
    
    
    $connection->query("UPDATE redirect_sets SET set_name = '$redirectSetName' WHERE id = '$redirectSetId'");

    $urls = $_POST['redirect'];

 $connection->query("DELETE FROM redirects WHERE set_in = '$redirectSetId'");


for($d = 0; $d < count($urls); $d++)
{
    $redirectUrl = $urls[$d]['url'];
    $qRedirect = $connection->prepare("INSERT INTO redirects (url,set_in) VALUES (?,?)");
    $qRedirect->execute(["$redirectUrl","$redirectSetId"]);
    
}




?>