• 14-08-2024, 23:38:59
    #1
    <!-- Photo Upload Section -->
    <div class="row">
        <div class="col-md-6 mb-3">
            <div class="card">
                <div class="card-header">
                    <h5 class="font-weight-bold text-warning">Fotoğraflarım</h5>
                </div>
                <div class="card-body">
                    <div class="row custom-photo-row">
                        <!-- Araç Resmi -->
                        <div class="custom-photo-column text-center mb-3">
                            <h6 class="font-weight-bold">Araç Resmi</h6>
                            <?php
                            $vehicleSrc = "Uyeler/User-" . htmlspecialchars($_SESSION["user"]["Uye_Kimlik"]) . "/" . htmlspecialchars($_SESSION["user"]["Uye_Arac_Resmi"]);
                            if (!empty($_SESSION["user"]["Uye_Arac_Resmi"]) && file_exists($vehicleSrc)) {
                                ?>
                                <div class="image-container">
                                    <a href="#" data-toggle="modal" data-target="#vehicleModal">
                                        <img src="<?= htmlspecialchars($vehicleSrc) ?>" class="img-fluid img-thumbnail custom-photo-size" alt="Araç Resmi">
                                    </a>
                                    <button type="button" class="btn btn-link btn-sm image-delete-button" onclick="confirmDelete('Arac_Resmi_Sil')">
                                        <i class="ri-close-line" style="font-size: 24px;"></i>
                                    </button>
                                </div>
                                <?php
                            } else {
                                ?>
                                <div class="form-group">
                                    <p>Araç Resmi Yüklenmedi.</p>
                                </div>
                                <?php
                            }
                            ?>
                        </div>
                        <!-- Profil Resmi -->
                        <div class="custom-photo-column text-center mb-3">
                            <h6 class="font-weight-bold">Profil Resmi</h6>
                            <?php
                            $profileSrc = "Uyeler/User-" . htmlspecialchars($_SESSION["user"]["Uye_Kimlik"]) . "/" . htmlspecialchars($_SESSION["user"]["Uye_Profil_Resmi"]);
                            if (!empty($_SESSION["user"]["Uye_Profil_Resmi"]) && file_exists($profileSrc)) {
                                ?>
                                <div class="image-container">
                                    <a href="#" data-toggle="modal" data-target="#profileModal">
                                        <img src="<?= htmlspecialchars($profileSrc) ?>" class="img-fluid img-thumbnail custom-photo-size" alt="Profil Resmi">
                                    </a>
                                    <button type="button" class="btn btn-link btn-sm image-delete-button" onclick="confirmDelete('Profil_Resim_Sil')">
                                        <i class="ri-close-line" style="font-size: 24px;"></i>
                                    </button>
                                </div>
                                <?php
                            } else {
                                ?>
                                <div class="form-group">
                                    <p>Profil Resmi Yüklenmedi.</p>
                                </div>
                                <?php
                            }
                            ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
    const userKimlik = <?= json_encode($_SESSION["user"]["Uye_Kimlik"]); ?>;
    function confirmDelete(action) {
        Swal.fire({
            title: 'Silmek istediğinize emin misiniz?',
            icon: 'warning',
            showCancelButton: true,
            cancelButtonColor: '#3085d6',
            confirmButtonColor: '#d33',
            cancelButtonText: 'İptal',
            confirmButtonText: 'Sil'
        }).then((result) => {
            if (result.isConfirmed) {
                window.location.href = `ayar/ajax.php?${action}&Kimlik=${userKimlik}`;
            }
        });
    }
    </script>


    ajax.php

    if (isset($_GET["Arac_Resmi_Sil"]) && isset($_GET["Kimlik"])) {
        $Kimlik = $_GET["Kimlik"];
        $Resim_Text = $_SESSION["user"]["Uye_Arac_Resmi"];
        $Arac_Resmi = "../Uyeler/User-" . $Kimlik . "/" . $Resim_Text;
        echo "Dosya yolu: " . $Arac_Resmi; // Dosya yolunu kontrol etmek için
        if (file_exists($Arac_Resmi)) {
            if (unlink($Arac_Resmi)) {
                // File successfully deleted
                $query = "UPDATE Uyeler SET Uye_Arac_Resmi = NULL WHERE Uye_Kimlik = ?";
                $stmt = $db->prepare($query);
                $stmt->execute([$Kimlik]);
                header("Location: ../Uye_KBilgilerim.php?Durum=Silindi");
                exit;
            } else {
                header("Location: ../Uye_KBilgilerim.php?Durum=Silinemedi");
                exit;
            }
        } else {
            header("Location: ../Uye_KBilgilerim.php?Durum=Silinemedi");
            exit;
        }
    }
    if (isset($_GET["Profil_Resim_Sil"]) && isset($_GET["Kimlik"])) {
        $Kimlik = $_GET["Kimlik"];
        $Resim_Text = $_SESSION["user"]["Profil_Resim_Sil"];
        $Arac_Resmi = "../Uyeler/User-" . $Kimlik . "/" . $Resim_Text;
        if (file_exists($Arac_Resmi)) {
            if (unlink($Arac_Resmi)) {
                $query = "UPDATE Uyeler SET Profil_Resim_Sil = NULL WHERE Uye_Kimlik = ?";
                $stmt = $db->prepare($query);
                $stmt->execute([$Kimlik]);
                header("Location: ../Uye_KBilgilerim.php?Durum=Silindi");
                exit;
            } else {
                header("Location: ../Uye_KBilgilerim.php?Durum=Silinemedi");
                exit;
            }
        } else {
            header("Location: ../Uye_KBilgilerim.php?Durum=Silinemedi");
            exit;
        }
    }

    Url uzantımda Durum=No olarak geri dönüş alıyorum ,
    Profil_Guncelle butonu var ayrıtten onunlamı çakışıyor anlamadım resmi silmiyor, veritabanına da işlem sağlamıyor
    anydesk ile yardımcı olabilecek var mı ?
  • 14-08-2024, 23:41:42
    #2
    🏆 Wordpress Uzmanı
    Merhaba, ücretli yardımcı olabilirim.
  • 15-08-2024, 00:29:14
    #3
    Büyük ihtimalle çakışma oluyor. Ajax.php de print_r ile gelen get değerlerine bakıp doğru şekilde veriyi yolluyor musun bak bi