Не получается записать данные в базу. Почему - не знаю) Скажу сказу я только учусь!

Не получается записать данные в бд через ajax. Это в script.js

$('.edit_news').click(function (e) {
            e.preventDefault();

            let title = $('input[name="title"]').val(),
                id = $(this).attr('id'),
                url = $('input[name="url"]').val(),
                text = $('textarea[name="text"]').val();

            let formData = new FormData();
            formData.append('title', title);
            formData.append('id', id);
            formData.append('text', text);
            formData.append('url', url);
            formData.append('photo', photo);

            $.ajax({
                url: '/include/edit/edit_news.php',
                type: 'POST',
                dataType: 'json',
                processData: false,
                contentType: false,
                cache: false,
                data: formData,
                success(data) {
                    if (data.status) {
                        if (notyf.success(data.message)) {
                            window.setTimeout(function () {
                                document.location.href = '/news';
                            }, 3000);
                        }
                    } else {
                        danger_notyf.error(data.message);
                    }
                }
            })
        });

Это в edit_news.php

<?php
include_once 'include/head.php';
include_once 'include/db.php';
if (isset($_GET['id'])) {
    $id = $_GET['id'];
    $select = mysqli_query($connect, "SELECT * FROM `news` WHERE `id` = '$id'");
    $row = mysqli_fetch_array($select);
    foreach ($select as $row) {
        $title = $row['title'];
        $text = $row['text'];
        $url = $row['url'];
        $photo = $row['photo'];
        $date = $row['date'];
    }
}
?>
<body class="sb-nav-fixed">
<?php include_once 'include/nav.php' ?>
<div id="layoutSidenav">
    <?php include_once 'include/menu.php' ?>
    <div id="layoutSidenav_content">
        <main id="swup" class="transition-fade">
            <div class="container-fluid">
                <h1 class="mt-4 text-center">Редактировать новость</h1>
                <div class="form-group">
                    <label for="id">ID:</label>
                    <input type="text" id="<?php echo $_GET['id']?>" value="<?php echo $_GET['id']?>" disabled class="form-control">
                </div>
                <div class="form-group">
                    <label for="title">Заголовок:</label>
                    <input type="text" id="title" name="title" value="<?php echo $title ?>" class="form-control"
                           placeholder="Введите заголовок">
                </div>
                <div class="form-group">
                    <label for="text">Текст:</label>
                    <textarea id="text" class="form-control" rows="5" style="resize: none" type="text" name="text"
                              placeholder="Введите текст"><?php echo $text ?></textarea>
                </div>
                <div class="custom-control custom-checkbox text-danger">
                    <input type="checkbox" class="custom-control-input" id="switch">
                    <label class="custom-control-label" for="switch">Ввести остальные данные</label>
                </div>
                <div class="form-group">
                    <label for="url">Ссылка на источник</label>
                    <input type="text" id="url" name="url" value="<?php echo $url ?>" class="form-control"
                           placeholder="Введите ссылку на источник"
                           disabled>
                </div>
                <div class="form-group">
                    <label>Картинка:</label>
                    <input class="form-control" multiple accept="image/*,image/jpeg"
                           type="file" name="photo" disabled>
                    <?php
                    if ($photo != 'NULL'):?>
                        <img class="card-img" src="<?php echo $photo ?>">
                    <?php endif; ?>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-success float-right edit_news"><span
                                class="fa fa-edit"></span> Редактировать
                    </button>
                </div>
            </div>
        </main>
    </div>
</div>
<?php include_once 'include/footer.php'; ?>

Сам обработчик:

<?php
require_once '../db.php';
$id = mysqli_real_escape_string($connect, $_POST['id']);
$title = mysqli_real_escape_string($connect, $_POST['title']);
$text = mysqli_real_escape_string($connect, $_POST['text']);
$url = mysqli_real_escape_string($connect, $_POST['url']);
$timezone = date_default_timezone_set('Asia/Yekaterinburg');
$data = date('Y-m-d');
$file = isset($_FILES['photo']['name']);
$order = array("*");
$replace = '<br>';
$newstr = str_replace($order, $replace, $text);
$empty = empty($url) or empty($file);
$two = !empty($title) and !empty($text);
if ($two) {
    mysqli_query($connect, "UPDATE `news` SET `title` = '$title',`text` = '$newstr',`url` = '$url' WHERE `id` = '$id'");
    $response = [
        "status" => true,
        "message" => 'Успешно обновили новость!'
    ];
    echo json_encode($response);
} elseif (!empty($title) and !empty($text) and !empty($file)) {
    $path = '../uploads/' . $data . $_FILES['photo']['name'];
    if (!move_uploaded_file($_FILES['photo']['tmp_name'], '../' . $path)) {
        $response = [
            "status" => false,
            "message" => 'Ошибка при отправке фото на сайт!'
        ];
        echo json_encode($response);
        die();
    }
    mysqli_query($connect, "UPDATE `news` SET `title` = '$title',`text` = '$newstr',`url` = '$url',`photo` = '$path' WHERE `id` = '$id'");
    $response = [
        "status" => true,
        "message" => 'Успешно обновили новость!'
    ];
    echo json_encode($response);
} elseif (empty($title) or empty($text)) {
    $response = [
        "status" => false,
        "message" => 'Заголовок или описание не заполнено!'
    ];
    echo json_encode($response);
}

Ответы (1 шт):

Автор решения: AiRNET Production

ajax.js:

Вместо: id = $(this).attr('id'), Пишем: id = $('input[name="id"]').val(),

и того - всё работает, может быть что-то упустил... но работает)

→ Ссылка