File Manager
Editing: profile.php
<?php // Enable error reporting for debugging //ini_set('display_errors', 1); //ini_set('display_startup_errors', 1); //error_reporting(E_ALL); // Include the shared functions file require_once 'security.php'; require_once 'functions.php'; session_start(); $host = "127.0.0.1:3306"; $username = "u404542307_dacotywebsites"; $password = "daCotywebs1te5"; $database = "u404542307_eizon"; try { // Establish database connection $pdo = new PDO("mysql:host=$host;dbname=$database", $username, $password); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die("Could not connect to the database: " . $e->getMessage()); } // Check if 'user' is set in the query string if (isset($_GET['user'])) { $username = htmlspecialchars(trim($_GET['user'])); // Sanitize the input } // Fetch data from profiles first (handles all credentials) $stmt = $pdo->prepare("SELECT * FROM profiles WHERE username = :username"); $stmt->bindParam(':username', $username, PDO::PARAM_STR); $stmt->execute(); $profile = $stmt->fetch(PDO::FETCH_ASSOC); // If no profile is found, fetch the username from the users table and match user_id in profiles if (!$profile) { // Fetch only the username from users table $stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username"); $stmt->bindParam(':username', $username, PDO::PARAM_STR); $stmt->execute(); $user = $stmt->fetch(PDO::FETCH_ASSOC); if ($user) { // If user exists in users table, get the user_id $userId = $user['id']; // Now fetch the profile details using the user_id $stmt = $pdo->prepare("SELECT * FROM profiles WHERE user_id = :user_id"); $stmt->bindParam(':user_id', $userId, PDO::PARAM_INT); $stmt->execute(); $profile = $stmt->fetch(PDO::FETCH_ASSOC); if ($profile) { // Use username from users table and profile details from profiles table $display_name = htmlspecialchars($user['username']); $bio = htmlspecialchars($profile['description'] ?? "No description added."); $countryCode = $profile['country_code'] ?? ''; $phoneNumber = $profile['phone_number'] ?? ''; $profilePhoneNumber = $countryCode . $phoneNumber; $userId = $profile['user_id']; // Ensure correct user_id from profiles table } } } else { // Profile found, use its details $display_name = htmlspecialchars($profile['username']); $bio = htmlspecialchars($profile['description'] ?? "No description added."); $countryCode = $profile['country_code'] ?? ''; $phoneNumber = $profile['phone_number'] ?? ''; $profilePhoneNumber = $countryCode . $phoneNumber; $userId = $profile['user_id']; // Ensure correct user_id from profiles table } // Fetch user's products from the database, ordered by the most recent first $sql = "SELECT * FROM cards WHERE user_id = :user_id ORDER BY created_at DESC"; $stmt = $pdo->prepare($sql); $stmt->bindParam(':user_id', $userId, PDO::PARAM_INT); $stmt->execute(); $products = $stmt->fetchAll(PDO::FETCH_ASSOC); // Set the title username $titleUsername = $display_name; // Generate full URL for the profile image $base_url = "https://www.eizononline.com"; $profile_image_url = !empty($profile['profile_image']) ? $base_url . '/' . $profile['profile_image'] // Remove the extra 'uploads/' prefix : $base_url . '/images/profile_avatar.jpg'; // Fallback to a default avatar // ================================================== // CUSTOMER COUNT TRACKING USING IP ADDRESS // ================================================== // Get the visitor's IP address $visitor_ip = $_SERVER['REMOTE_ADDR']; // Insert a visit record into the customer_count table if ($userId) { $stmt = $pdo->prepare("INSERT INTO customer_count (user_id, visitor_ip) VALUES (:user_id, :visitor_ip)"); $stmt->execute([ ':user_id' => $userId, ':visitor_ip' => $visitor_ip ]); } // ================================================== // END OF CUSTOMER COUNT TRACKING // ================================================== // Rest of your profile.php code... ?> <!DOCTYPE html> <html lang="en"> <head> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-Z6RR2PMZW4"></script> <script defer> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-Z6RR2PMZW4'); </script> <meta charset="UTF-8"> <title><?php echo $titleUsername; ?> - Profile</title> <meta property="og:title" content="Check out <?php echo $display_name; ?>'s products on eizon!" /> <meta property="og:description" content="<?php echo $bio; ?>" /> <meta property="og:image" content="<?= htmlspecialchars($profile_image_url); ?>"> <meta property="og:image:width" content="1200"> <meta property="og:image:height" content="630"> <meta property="og:url" content="https://eizononline.com/profile.php?user=<?php echo urlencode($username); ?>" /> <meta property="og:type" content="profile" /> <meta property="og:site_name" content="Eizon"> <link rel="stylesheet" href="accounts.css"> <link rel="stylesheet" href="e-commerce.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"> <link rel="manifest" href="/manifest.json"> <style> .namekit{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;white-space:normal;-webkit-line-clamp:2;} /* Footer styles */ footer { background: #1b5e20; color: white; border-radius: 15px 15px 0 0; } /* Mobile Bottom Navigation */ .mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: white; box-shadow: 0 -2px 20px rgba(0,0,0,0.15); z-index: 1000; padding: 10px 0; } .nav-items { display: flex; justify-content: space-around; list-style: none; } .nav-item { display: flex; flex-direction: column; align-items: center; text-align: center; flex: 1; } .nav-item a { display: flex; flex-direction: column; align-items: center; text-decoration: none; color: #40e351; font-size: 0.75rem; padding: 5px 0; width: 100%; } .nav-item i { font-size: 1.4rem; margin-bottom: 4px; transition: color 0.3s; } .nav-item.active a { color: #2e7d32; } .nav-item.active i { color: #ff9800; } .nav-item:hover i { color: #43a047; } /* Show mobile nav only on mobile screens */ @media (max-width: 768px) { .mobile-nav { display: block; } body { padding-bottom: 70px; } } </style> </head> <body> <?php include 'header.php'; ?> <div class="dashbanner-profile" style="background-image: url('<?php echo htmlspecialchars(!empty($profile['banner_image']) ? $profile['banner_image'] : 'images/may3.webp'); ?>');background-position:center;background-size:100% 100%;"> <div class="dashboard"> <div class="profile" style="background-image: url('<?php echo htmlspecialchars($profile['profile_image'] ?? 'images/profile_avatar.jpg'); ?>');background-position:center; background-size:100% 100%;background-repeat:no-repeat;"> </div> <div class="business-name"> <h2 style="margin:0;text-align:center;">Welcome to, </h2> <h4 style="margin:0;text-align:center;padding:1px;"> <?php echo $titleUsername; ?>!</h4> </div> <div> <?php if (!empty($profilePhoneNumber)): ?> <button class="profile-contact" onclick="window.location.href='https://wa.me/<?php echo htmlspecialchars($profilePhoneNumber); ?>?text=Habari!%20 <?php echo urlencode($titleUsername); ?>%20I%20like%20your%20products%20on%20eizononline.com';"> Message </button> <?php endif; ?> </div> </div> <div class="aboutbusiness"> <p><?php echo !empty($profile['description']) ? htmlspecialchars($profile['description']) : "No description added."; ?></p> </div> </div> <!-- Products Section --> <div class="products-section"> <?php if ($products): ?> <div class="products"> <?php foreach ($products as $row): ?> <?php // Combine country_code and contacts $countryCode = $row['country_code']; // Fetch country code from the database $phoneNumber = $row['contacts']; // Fetch phone number from the database // Format the full phone number $fullPhoneNumber = $countryCode . $phoneNumber; ?> <div class="generalcard"> <div class="card"> <div class="card-inner"> <!-- Front of the Card --> <div class="card-front"> <div class="slideshow"> <?php if (!empty($row['image1'])): ?> <img src="<?php echo htmlspecialchars($row['image1']); ?>" alt="Image 1"> <?php endif; ?> <?php if (!empty($row['image2'])): ?> <img src="<?php echo htmlspecialchars($row['image2']); ?>" alt="Image 2"> <?php endif; ?> <?php if (!empty($row['image3'])): ?> <img src="<?php echo htmlspecialchars($row['image3']); ?>" alt="Image 3"> <?php endif; ?> </div> </div> <!-- Back of the Card --> <div class="card-back"> <h3 class="namekit"><?php echo htmlspecialchars($row['name']); ?></h3> <p class="over"><?php echo htmlspecialchars($row['description']); ?></p> <p><?php echo htmlspecialchars($row['state']); ?></p> <p> <a href="/product.php?card_id=<?= htmlspecialchars($row['card_id']) ?>">More Details</a> </p> <!-- Updated BUY Button --> <button onclick="window.location.href='https://wa.me/<?= htmlspecialchars($fullPhoneNumber) ?>?text=Habari!%20I%20am%20interested%20in%20your%20product%20<?= urlencode($row['name']) ?>%20on%20eizon%20:%20<?= urlencode('https://www.eizononline.com/product.php?card_id=' . $row['card_id']) ?>';"> BUY </button> </div> </div> </div> <!-- Price Tag --> <div class="pricetag"> <p><?= htmlspecialchars(number_format($row['price'], 2)) ?> Tsh</p> </div> </div> <?php endforeach; ?> </div> <?php else: ?> <p>No products have been uploaded.</p> <?php endif; ?> </div> <footer> <div class="socialmediaicons"> <hr> <div class="socials"> <a href="https://www.instagram.com/eizononline"> <i class="fa-brands fa-square-instagram"></i> </a> <a href="https://www.facebook.com/eizononline/"> <i class="fa-brands fa-facebook"></i> </a> <a href="https://chat.whatsapp.com/BjYHA7zTwzN0EA0cdZJnzd"> <i class="fa-brands fa-square-whatsapp"></i> </a> </div> <hr> </div> <div class="footerlogo"> <h1>e!zon</h1> <p>Copyright ©<?= date('Y'); ?> eizon, a daCotyINDUSTRY Company. All Rights Reserved.</p> </div> </footer> <!-- Mobile Bottom Navigation --> <nav class="mobile-nav"> <ul class="nav-items" style="padding-left:0px;margin:0;"> <li class="nav-item active"> <a href="/home"> <i class="fas fa-home"></i> <span>Home</span> </a> </li> <li class="nav-item"> <a href="/allproducts"> <i class="fas fa-shopping-cart"></i> <span>Shop</span> </a> </li> <li class="nav-item"> <a href="/sell"> <i class="fas fa-plus-circle"></i> <span>Add Product</span> </a> </li> <li class="nav-item"> <a href="/requests_page"> <i class="fas fa-clipboard-list"></i> <span>Request</span> </a> </li> <li class="nav-item"> <a href="/dashboard"> <i class="fas fa-user"></i> <span>Account</span> </a> </li> </ul> </nav> <script src="e-commerce.js"></script> <script> document.addEventListener("DOMContentLoaded", function () { const currentPath = window.location.pathname; const navItems = document.querySelectorAll(".mobile-nav .nav-item"); let matched = false; navItems.forEach(item => { const link = item.querySelector("a"); const linkPath = link.getAttribute("href"); let isActive = false; // ✅ Special cases if (linkPath === "/sell" && (currentPath.startsWith("/sell") || currentPath.startsWith("/addproduct"))) { isActive = true; // /sell OR /addproduct = Add Product } else if (linkPath === "/dashboard" && currentPath.startsWith("/dashboard")) { isActive = true; // /dashboard/* = Account } else if (linkPath === "/allproducts" && (currentPath.startsWith("/products") || currentPath.startsWith("/regions"))) { isActive = true; // /products/* or /regions/* = Shop } else if (currentPath === linkPath || currentPath.startsWith(linkPath + "/")) { isActive = true; // Normal match } if (isActive) { item.classList.add("active"); matched = true; } else { item.classList.remove("active"); } }); // ✅ Fallback: Home if nothing else matches if (!matched) { const homeItem = document.querySelector('.mobile-nav .nav-item a[href="/home"]')?.parentElement; if (homeItem) homeItem.classList.add("active"); } }); </script> <?php include_once __DIR__ . '/cordova-bridge.php'; ?> </body> </html>
💾 Save
⬅ Back