• 26-02-2025, 13:37:28
    #1
    Blog details sayfamvar ve tüm bilgileri çekiyor ancak title ve
    description kısımına gelince işler biraz karıştı blog-details.php?id=17 bu şekilde id ile çekiyor anca title ve description bir türlü çektiremedim yardım edecek birisi varmıdır kodu paylaşıyorum.

    details sayfamda id ye göre title çekmiyor kodum bu şekilde yardımcı olacak biri ulaşabilirmi.

    <?php
    include 'header.php';
     
    if (isset($_GET['id'])) {
        $id = intval($_GET['id']);
     
        $stmt = $pdo->prepare("SELECT * FROM bloglar WHERE id = ?");
        $stmt->execute([$id]);
        $blog = $stmt->fetch(PDO::FETCH_ASSOC);
     
        if ($blog) {
            $sayfa_baslik = !empty($blog['baslik']) ? $blog['baslik'] : "Blog";
            $sayfa_aciklama = !empty($blog['aciklama']) ? strip_tags($blog['aciklama']) : "hakkında en güncel blog yazıları burada.";
            $sayfa_resim = !empty($blog['resim_yolu']) ? './admin/' . $blog['resim_yolu'] : "./admin/default-image.jpg";
            $sayfa_anahtarkelime = !empty($blog['etiket']) ? $blog['etiket'] : ", blog, konaklama";
            $tarih = !empty($blog['tarih']) ? $blog['tarih'] : date("Y-m-d");
        } else {
            header("Location: blog.php");
            exit;
        }
    } else {
        header("Location: blog.php");
        exit;
    }
    ?>
     
    <!DOCTYPE html>
    <html lang="tr">
     
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title><?php echo htmlspecialchars($sayfa_baslik); ?></title>
        <meta name="description" content="<?php echo htmlspecialchars(mb_substr($sayfa_aciklama, 0, 160, 'UTF-8')); ?>">
        <meta name="keywords" content="<?php echo htmlspecialchars($sayfa_anahtarkelime); ?>">
     
        <meta property="og:title" content="<?php echo htmlspecialchars($sayfa_baslik); ?>">
        <meta property="og:description" content="<?php echo htmlspecialchars(mb_substr($sayfa_aciklama, 0, 160, 'UTF-8')); ?>">
        <meta property="og:image" content="<?php echo htmlspecialchars($sayfa_resim); ?>">
        <meta property="og:type" content="article">
        <meta property="og:url" content="..r/blog-details.php?id=<?php echo $id; ?>">
     
        <meta name="twitter:card" content="summary_large_image">
        <meta name="twitter:title" content="<?php echo htmlspecialchars($sayfa_baslik); ?>">
        <meta name="twitter:description" content="<?php echo htmlspecialchars(mb_substr($sayfa_aciklama, 0, 160, 'UTF-8')); ?>">
        <meta name="twitter:image" content="<?php echo htmlspecialchars($sayfa_resim); ?>">
     
        <style>
            .single-media .media-photo {
                width: 100%;
                height: 400px;
                display: flex;
                align-items: center;
                justify-content: center;
                overflow: hidden;
            }
            .single-media .media-photo img {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }
             
            .widget-blog-single .single-detail {
                margin-top: 20px;
                line-height: 1.6;
            }
            .widget-blog-single .single-detail h2 {
                font-size: 2.5rem;
                font-weight: bold;
                margin-bottom: 20px;
            }
            .widget-blog-single .single-detail p {
                font-size: 1.1rem;
                color: #444;
            }
             
            .blog-tags {
                margin-top: 20px;
            }
            .blog-tags .etiket {
                display: inline-block;
                background: #f1f1f1;
                color: #333;
                padding: 6px 15px;
                margin-right: 10px;
                margin-top: 10px;
                border-radius: 30px;
                font-size: 14px;
                text-transform: capitalize;
                transition: background 0.3s ease;
            }
            .blog-tags .etiket:hover {
                background: #007BFF;
                color: white;
            }
             
            .widget-breadcrumb {
                margin-top: 20px;
            }
            .widget-breadcrumb ul {
                list-style-type: none;
                padding: 0;
            }
            .widget-breadcrumb ul li {
                display: inline;
                margin-right: 10px;
            }
            .widget-breadcrumb ul li a {
                color: #007BFF;
                text-decoration: none;
            }
            .widget-breadcrumb ul li::after {
                content: " /";
                margin-left: 10px;
            }
            .widget-breadcrumb ul li:last-child::after {
                content: "";
            }
     
            @media (max-width: 768px) {
                .single-media .media-photo {
                    height: 300px;
                }
                .widget-blog-single .single-detail h2 {
                    font-size: 2rem;
                }
                .widget-blog-single .single-detail p {
                    font-size: 1rem;
                }
            }
        </style>
    </head>
    <body>
     
    <div class="site-main">
        <div class="section">
            <div class="widget-page-title">
                <div class="widget-background" data-background="<?php echo htmlspecialchars($sayfa_resim); ?>"></div>
                <div class="wrapper-inner">
                    <h5></h5>
                    <h1><?php echo htmlspecialchars($sayfa_baslik); ?></h1>
                    <div class="widget-breadcrumb">
                        <ul>
                            <li><a href="../index.php">Anasayfa</a></li>
                            <li><?php echo htmlspecialchars($sayfa_baslik); ?></li>
                        </ul>
                    </div>
                </div>
            </div>
             
            <div class="wrapper-inner">
                <div class="widget-blog-single">
                    <div class="single-media">
                        <div class="media-photo">
                            <a href="<?php echo htmlspecialchars($sayfa_resim); ?>" title="<?php echo htmlspecialchars($sayfa_baslik); ?>" class="popup-photo">
                                <img src="<?php echo htmlspecialchars($sayfa_resim); ?>" alt="<?php echo htmlspecialchars($sayfa_baslik); ?>">
                            </a>
                        </div>
                    </div>
     
                    <div class="single-detail">
                        <div class="detail-head">
                            <a href="#"></a> <i class="fa fa-clock-o"></i> <?php echo htmlspecialchars($tarih); ?>
                        </div>
                        <div class="detail-content">
                            <h2><?php echo htmlspecialchars($sayfa_baslik); ?></h2>
                            <p><?php echo nl2br(htmlspecialchars($sayfa_aciklama)); ?></p>
     
                            <div class="blog-tags">
                                <?php
                                $etiketler = explode(',', $sayfa_anahtarkelime);
                                foreach ($etiketler as $etiket) {
                                    echo '<span class="etiket">' . htmlspecialchars(trim($etiket)) . '</span> ';
                                }
                                ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
     
    <?php include 'footer.php'; ?>
     
    </body>
    </html>
  • 26-02-2025, 13:42:07
    #2
    16. satırın altına
    file_put_contents("blog.txt", json_encode($blog));
    ekleyip sayfayı yenileyin, siteadresiniz.com/blog.txt dosyasında ne görüyorsunuz?
  • 26-02-2025, 13:42:13
    #3
    rust desk id atarsanız bakalım hocam (anydesk yada teamviewer vs. kabul etmiyorum)

    https://rustdesk.com/
  • 26-02-2025, 13:44:19
    #4
    SauRonn adlı üyeden alıntı: mesajı görüntüle
    16. satırın altına
    file_put_contents("blog.txt", json_encode($blog));
    ekleyip sayfayı yenileyin, siteadresiniz.com/blog.txt dosyasında ne görüyorsunuz?
    {"id":3,"baslik":"arda tester","aciklama":"tersdfds","etiket":"arda tester","tarih":"2025-02-26 11:01:18","resim":"1740564078_Sade Basit u015eu0131k Kahve Logosu (190 x 70 piksel).png","resim_yolu":"1740564078_Sade Basit u015eu0131k Kahve Logosu (190 x 70 piksel).png","dosya_yolu":"blog/arda-tester-1740564078.php"} hocam onu bunlar çıkıyor site görüyor ama yazmıyor canlıya attım yine aynı sorun var {"id":3,"baslik":"arda tester","aciklama":"tersdfds","etiket":"arda tester","tarih":"2025-02-26 11:01:18","resim":"1740564078_Sade Basit u015eu0131k Kahve Logosu (190 x 70 piksel).png","resim_yolu":"1740564078_Sade Basit u015eu0131k Kahve Logosu (190 x 70 piksel).png","dosya_yolu":"blog/arda-tester-1740564078.php"}




    $debug = false; 
    if (isset($_GET['id'])) {
        $id = intval($_GET['id']);
        
        if ($debug) {
            echo "<div style='background: #f8f9fa; border: 1px solid #ddd; padding: 10px; margin: 10px 0;'>";
            echo "<h3>Debug Bilgileri:</h3>";
            echo "ID değeri: " . $id . "<br>";
        }
     
        $stmt = $pdo->prepare("SELECT * FROM bloglar WHERE id = ?");
        $stmt->execute([$id]);
        $blog = $stmt->fetch(PDO::FETCH_ASSOC);
        
        if ($debug && $blog) {
            echo "Blog verisi bulundu!<br>";
            echo "Başlık: " . $blog['baslik'] . "<br>";
            echo "Açıklama: " . substr($blog['aciklama'], 0, 100) . "...<br>";
            echo "</div>";
        } elseif ($debug) {
            echo "Blog verisi bulunamadı!<br>";
            echo "SQL sorgusu: SELECT * FROM bloglar WHERE id = " . $id . "<br>";
            echo "</div>";
        }
     
        if ($blog) {
            $sayfa_baslik = isset($blog['baslik']) && !empty($blog['baslik']) ? $blog['baslik'] : "Blog";
            
            $sayfa_aciklama = isset($blog['aciklama']) && !empty($blog['aciklama']) 
                ? strip_tags($blog['aciklama']) 
                : "hakkında en güncel blog yazıları burada.";
                
            $sayfa_resim = isset($blog['resim_yolu']) && !empty($blog['resim_yolu']) 
                ? './admin/' . $blog['resim_yolu'] 
                : "./admin/default-image.jpg";
                
            $sayfa_anahtarkelime = isset($blog['etiket']) && !empty($blog['etiket']) 
                ? $blog['etiket'] 
                : ", blog, konaklama";
                
            $tarih = isset($blog['tarih']) && !empty($blog['tarih']) 
                ? date("d.m.Y", strtotime($blog['tarih'])) 
                : date("d.m.Y");
        } else {
            header("Location: blog.php");
            exit;
        }
    } else {
        header("Location: blog.php");
        exit;
    }
  • 26-02-2025, 13:47:13
    #5
    m4lisen adlı üyeden alıntı: mesajı görüntüle
    rust desk id atarsanız bakalım hocam (anydesk yada teamviewer vs. kabul etmiyorum)

    https://rustdesk.com/
    indiriyorum
  • 26-02-2025, 13:50:43
    #6
    Merhabalar, Kodda $pdo değişkeni tanımlı değil. Eğer veritabanı bağlantın db.php gibi bir dosyada tanımlıysa, onu include 'db.php'; ile eklediğinden emin ol.

    Aryax adlı üyeden alıntı: mesajı görüntüle
    Blog details sayfamvar ve tüm bilgileri çekiyor ancak title ve
    description kısımına gelince işler biraz karıştı blog-details.php?id=17 bu şekilde id ile çekiyor anca title ve description bir türlü çektiremedim yardım edecek birisi varmıdır kodu paylaşıyorum.

    details sayfamda id ye göre title çekmiyor kodum bu şekilde yardımcı olacak biri ulaşabilirmi.

    <?php
    include 'header.php';
     
    if (isset($_GET['id'])) {
        $id = intval($_GET['id']);
     
        $stmt = $pdo->prepare("SELECT * FROM bloglar WHERE id = ?");
        $stmt->execute([$id]);
        $blog = $stmt->fetch(PDO::FETCH_ASSOC);
     
        if ($blog) {
            $sayfa_baslik = !empty($blog['baslik']) ? $blog['baslik'] : "Blog";
            $sayfa_aciklama = !empty($blog['aciklama']) ? strip_tags($blog['aciklama']) : "hakkında en güncel blog yazıları burada.";
            $sayfa_resim = !empty($blog['resim_yolu']) ? './admin/' . $blog['resim_yolu'] : "./admin/default-image.jpg";
            $sayfa_anahtarkelime = !empty($blog['etiket']) ? $blog['etiket'] : ", blog, konaklama";
            $tarih = !empty($blog['tarih']) ? $blog['tarih'] : date("Y-m-d");
        } else {
            header("Location: blog.php");
            exit;
        }
    } else {
        header("Location: blog.php");
        exit;
    }
    ?>
     
    <!DOCTYPE html>
    <html lang="tr">
     
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title><?php echo htmlspecialchars($sayfa_baslik); ?></title>
        <meta name="description" content="<?php echo htmlspecialchars(mb_substr($sayfa_aciklama, 0, 160, 'UTF-8')); ?>">
        <meta name="keywords" content="<?php echo htmlspecialchars($sayfa_anahtarkelime); ?>">
     
        <meta property="og:title" content="<?php echo htmlspecialchars($sayfa_baslik); ?>">
        <meta property="og:description" content="<?php echo htmlspecialchars(mb_substr($sayfa_aciklama, 0, 160, 'UTF-8')); ?>">
        <meta property="og:image" content="<?php echo htmlspecialchars($sayfa_resim); ?>">
        <meta property="og:type" content="article">
        <meta property="og:url" content="..r/blog-details.php?id=<?php echo $id; ?>">
     
        <meta name="twitter:card" content="summary_large_image">
        <meta name="twitter:title" content="<?php echo htmlspecialchars($sayfa_baslik); ?>">
        <meta name="twitter:description" content="<?php echo htmlspecialchars(mb_substr($sayfa_aciklama, 0, 160, 'UTF-8')); ?>">
        <meta name="twitter:image" content="<?php echo htmlspecialchars($sayfa_resim); ?>">
     
        <style>
            .single-media .media-photo {
                width: 100%;
                height: 400px;
                display: flex;
                align-items: center;
                justify-content: center;
                overflow: hidden;
            }
            .single-media .media-photo img {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }
            
            .widget-blog-single .single-detail {
                margin-top: 20px;
                line-height: 1.6;
            }
            .widget-blog-single .single-detail h2 {
                font-size: 2.5rem;
                font-weight: bold;
                margin-bottom: 20px;
            }
            .widget-blog-single .single-detail p {
                font-size: 1.1rem;
                color: #444;
            }
            
            .blog-tags {
                margin-top: 20px;
            }
            .blog-tags .etiket {
                display: inline-block;
                background: #f1f1f1;
                color: #333;
                padding: 6px 15px;
                margin-right: 10px;
                margin-top: 10px;
                border-radius: 30px;
                font-size: 14px;
                text-transform: capitalize;
                transition: background 0.3s ease;
            }
            .blog-tags .etiket:hover {
                background: #007BFF;
                color: white;
            }
            
            .widget-breadcrumb {
                margin-top: 20px;
            }
            .widget-breadcrumb ul {
                list-style-type: none;
                padding: 0;
            }
            .widget-breadcrumb ul li {
                display: inline;
                margin-right: 10px;
            }
            .widget-breadcrumb ul li a {
                color: #007BFF;
                text-decoration: none;
            }
            .widget-breadcrumb ul li::after {
                content: " /";
                margin-left: 10px;
            }
            .widget-breadcrumb ul li:last-child::after {
                content: "";
            }
     
            @media (max-width: 768px) {
                .single-media .media-photo {
                    height: 300px;
                }
                .widget-blog-single .single-detail h2 {
                    font-size: 2rem;
                }
                .widget-blog-single .single-detail p {
                    font-size: 1rem;
                }
            }
        </style>
    </head>
    <body>
     
    <div class="site-main">
        <div class="section">
            <div class="widget-page-title">
                <div class="widget-background" data-background="<?php echo htmlspecialchars($sayfa_resim); ?>"></div>
                <div class="wrapper-inner">
                    <h5></h5>
                    <h1><?php echo htmlspecialchars($sayfa_baslik); ?></h1>
                    <div class="widget-breadcrumb">
                        <ul>
                            <li><a href="../index.php">Anasayfa</a></li>
                            <li><?php echo htmlspecialchars($sayfa_baslik); ?></li>
                        </ul>
                    </div>
                </div>
            </div>
            
            <div class="wrapper-inner">
                <div class="widget-blog-single">
                    <div class="single-media">
                        <div class="media-photo">
                            <a href="<?php echo htmlspecialchars($sayfa_resim); ?>" title="<?php echo htmlspecialchars($sayfa_baslik); ?>" class="popup-photo">
                                <img src="<?php echo htmlspecialchars($sayfa_resim); ?>" alt="<?php echo htmlspecialchars($sayfa_baslik); ?>">
                            </a>
                        </div>
                    </div>
     
                    <div class="single-detail">
                        <div class="detail-head">
                            <a href="#"></a> <i class="fa fa-clock-o"></i> <?php echo htmlspecialchars($tarih); ?>
                        </div>
                        <div class="detail-content">
                            <h2><?php echo htmlspecialchars($sayfa_baslik); ?></h2>
                            <p><?php echo nl2br(htmlspecialchars($sayfa_aciklama)); ?></p>
     
                            <div class="blog-tags">
                                <?php
                                $etiketler = explode(',', $sayfa_anahtarkelime);
                                foreach ($etiketler as $etiket) {
                                    echo '<span class="etiket">' . htmlspecialchars(trim($etiket)) . '</span> ';
                                }
                                ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
     
    <?php include 'footer.php'; ?>
     
    </body>
    </html>
  • 26-02-2025, 14:06:22
    #7
    Hocam telefondaydım dönemedim kusura bakmayın. Arkadaş bakacak sanırım eğer olmazsa bana dönüş yaparsınız.
  • 26-02-2025, 14:09:45
    #8
    SauRonn adlı üyeden alıntı: mesajı görüntüle
    Hocam telefondaydım dönemedim kusura bakmayın. Arkadaş bakacak sanırım eğer olmazsa bana dönüş yaparsınız.
    header ile alakalı bir durum yaşanıyor, birden fazla proje var.
  • 26-02-2025, 14:12:26
    #9
    m4lisen adlı üyeden alıntı: mesajı görüntüle
    header ile alakalı bir durum yaşanıyor, birden fazla proje var.
    Hocam sayenizde fark ettim hatayı çözdüm şuanda teşkür ederim ilgi ve alakanız için