So I've been spending hours on finding something specific to my issue, but I can't seem to find any.
I'm in the middle of creating a small CMS. My problem is that I don't know how to make a submitted form in a UI dialog to do the action of PHP_SELF inside of the UI dialog. I have a list of user which can be selected by a radio button. There is a delete button which has some javascript attached:
$('#delete_user').on('click', function(e) {
    if (id != null ) {
        var url = "delete_user.php?id=" + id;
        $('#dialog-placeholder').dialog().load(url);
        $('.ui-dialog :button').blur();
    }
    e.preventDefault();
    return false;
});
Now, my problem is that I have made it to the UI dialog where i get the ID sent with the url, but I have no idea how to send a form and still keep it in the dialog with the underneath PHP:
    <?php 
if ((isset($_GET['id'])) && is_numeric($_GET['id'])) {
    $id = $_GET['id'];
} elseif ((isset($_POST['id'])) && is_numeric($_POST['id'])) {
    $id = $_POST['id'];
} else {
    echo "<p>An error has occurred. Please try again.</p>";
    echo "<a href=\"#\" class=\"close_dialog\">Close</a>";
$jQuery_close = <<<msg
<script>
    $('.close_dialog').on('click', function(){
        location.reload();
        dialog("close");
    });
</script>
msg;
echo $jQuery_close;
    exit();
}
require('includes/db_con.php'); //making a connection to the database
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($_POST['sure'] == 'Yes') {
        $q = "DELETE FROM users WHERE user_id=$id LIMIT 1";
        $r = @mysqli_query($dbc, $q);
        if (mysqli_affected_rows($dbc) == 1) {
            echo "<p>The user has been deleted</p>";
        } else {
            echo "<p>The user could not be deleted due to system error. Please try again.</p>";
        }
    } else {
        echo "The user has NOT been deleted!";
    }
} else {
    $q = "SELECT email, CONCAT(firstname, ' ',lastname) AS name FROM users WHERE user_id='$id'";
    $r = @mysqli_query($dbc, $q);
    $num = mysqli_num_rows($r);
    if ($num = 1) {
        while ($row = mysqli_fetch_array($r, MYSQL_ASSOC)) {
            echo "<p>Are you sure you want to delete this user?</p>";
            echo $row['email'] . '<br />';
            echo $row['name'];
        }
        echo '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">
        <input type="HIDDEN" name="id" value="' . $id .'" />
        <input type="submit" name="sure" value="Yes" />
        <input type="submit" name="sure" value="No" />
        </form>';   
    } else {
        echo "This page has been accessed in error";
    }
} 
mysqli_close($dbc);
?>
When pressing "yes" or "no" in the form, it just directly goes to a new page.
My question is, how do I fire the php and send the form within the dialog?
 
    