HEX
Server: Apache
System: Linux p3plzcpnl485017.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: rbrijwzv8p53 (8461783)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /home/rbrijwzv8p53/public_html/pdmc.org.pk/profile.php
<?php
session_start();
ini_set('display_errors', 1);
error_reporting(E_ALL);

$servername = "72.167.84.16";
$username = "pdmcsb";
$password = "pdmcdb@2104";
$database = "pdmcdb";

$conn = new mysqli($servername, $username, $password, $database);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

if (!isset($_SESSION['user_id']) || !isset($_SESSION['user_email'])) {
    // User is not logged in. Redirect them back to the login page
    header("Location: login.php?message=membership_required");
    exit;
}
// Clear the error message after displaying it
if (isset($_SESSION['error_message'])) {
    $error_message = $_SESSION['error_message'];
    unset($_SESSION['error_message']);
}
?><!DOCTYPE html>
<html lang="en">

<head>
    <style>
   #editProfileForm {
        max-width: 600px;
        margin: 0 auto;
    }

    form {
        padding: 20px;
        background-color: #f8f9fa;
        border-radius: 8px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }

    label {
        font-weight: bold;
        margin-bottom: 5px;
    }

    .editable-field {
        width: 100%;
        padding: 8px;
        margin-bottom: 15px;
        border: 1px solid #ced4da;
        border-radius: 4px;
        background-color: #fff;
    }

    .btn-primary {
        background-color: #007bff;
        border-color: #007bff;
    }

    .btn-success {
        background-color: #28a745;
        border-color: #28a745;
    }
  /* Styles for the overlay */
  .overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
  }

  /* Styles for the popup form */
  .popup-form {
    background: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    z-index: 1001;
  }
  .popup-form {
    max-width: 1200px; /* Adjust the width as needed */
  }
  /* Styles for the close button */
  .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
  }
</style>

  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title>Home PDMC - Index</title>
  <meta content="" name="description">
  <meta content="" name="keywords">

  <!-- Favicons -->
  <link href="assets/img/favicon.png" rel="icon">
  <link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">

  <!-- Google Fonts -->
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">

  <!-- Vendor CSS Files -->
  <link href="assets/vendor/aos/aos.css" rel="stylesheet">
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
  <link href="assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
  <link href="assets/vendor/remixicon/remixicon.css" rel="stylesheet">
  <link href="assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">
  <!-- Add these links to the head section of your HTML -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8sh+Wy6q8XPO4YlYRxl5eZO5etFhInN5f"
    crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
    crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js" integrity="sha384-Jo3UJSR+7hkmU1zLQse5LdRzcA7hU3K4zFu0Oq07p1wMfrQr35W7jjW1WOnmP0zZ"
    crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8sh+Wy6q8XPO4YlYRxl5eZO5etFhInN5f"
    crossorigin="anonymous"></script>

  <!-- Add these lines to your HTML head section -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>


  <!-- Template Main CSS File -->
  <link href="assets/css/style.css" rel="stylesheet">


</head>

<body>

  <!-- ======= Header ======= -->
 <header id="header" class="header fixed-top">
    <div class="container-fluid container-xl d-flex align-items-center justify-content-between">

      <a href="index.php" class="logo d-flex align-items-center">
        <img src="assets/img/logo.png" alt="">
        <span>PDMC</span>
      </a>

   <nav id="navbar" class="navbar">
    <ul>
        <li><a class="nav-link scrollto active" href="index.php">Home</a></li>
        <li><a class="nav-link scrollto" href="pdmc-member.php">PDMC Member</a></li>
        <li><a class="nav-link scrollto" href="membership.php">Membership</a></li>

        <?php
        if (isset($_SESSION['user_id']) && isset($_SESSION['user_email'])) {
            // User is logged in, show profile icon and dropdown menu
            $userId = $_SESSION['user_id'];
            $userEmail = $_SESSION['user_email'];

            $query = "SELECT * FROM request WHERE id = '$userId' AND Email = '$userEmail'";
            $result = mysqli_query($conn, $query);

            if (mysqli_num_rows($result) > 0) {
                $row = mysqli_fetch_assoc($result);
                echo '<li><a class="nav-link scrollto" href="partners.php">Partners</a></li>';
                echo '<li><a href="blog.php">Blog</a></li>';
                echo '<li><a class="nav-link scrollto" href="events.php">Events</a></li>';
                echo '<li><a class="nav-link scrollto" href="trainings.php">Trainings</a></li>';
                echo '<li><a class="nav-link scrollto" href="#contact">Contact</a></li>';

                $userName = $row['Fullname'];
                echo '<div class="dropdown">';
                echo '   ';
                echo '<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"><i class="fas fa-user-circle"></i> ' . $userName;
                echo '<span class="caret"></span></button>';
                echo '<ul class="dropdown-menu">';
                echo '<li><a href="profile.php">Profile</a></li>';
                echo '<li><a href="logout.php">Logout</a></li>';
                echo '</ul>';
                echo '</div>';
            }
        } else {
            // User is not logged in, show login and sign-up buttons
            echo '<li><a class="nav-link scrollto" href="login.php?message=membership_required">Partners</a></li>';
            echo '<li><a class="nav-link scrollto" href="login.php?message=membership_required">Blog</a></li>';
            echo '<li><a class="nav-link scrollto" href="login.php?message=membership_required">Events</a></li>';
            echo '<li><a class="nav-link scrollto" href="login.php?message=membership_required">Trainings</a></li>';
            echo '<li><a class="nav-link scrollto" href="login.php?message=membership_required">Contact</a></li>';
            echo '<li><a class="getstarted scrollto" href="login.php">Sign In</a></li>';
            echo '<li><a class="getstarted scrollto" href="becomemember.php">Become Member</a></li>';
        }
        ?>
        <i class="bi bi-list mobile-nav-toggle"></i>
    </ul>
</nav><!-- .navbar -->

    </div>
  </header><!-- End Header -->


 <main id="main">

    <!-- ======= Breadcrumbs ======= -->
    <section class="breadcrumbs">
      <div class="container">

        <ol>
          <li><a href="index.html">Home</a></li>
          <li>PDMC Members</li>
        </ol>
        <h2>Member Profile</h2>

      </div>
    </section><!-- End Breadcrumbs -->
<?php
// Check for a notification message

// Database credentials
$servername = "72.167.84.16";
$username = "pdmcsb";
$password = "pdmcdb@2104";
$database = "pdmcdb";

// Create connection
$conn = new mysqli($servername, $username, $password, $database);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Get user ID from the session
if (isset($_SESSION['user_id']) && isset($_SESSION['user_email'])) {
    $userId = $_SESSION['user_id'];
    $userEmail = $_SESSION['user_email'];

    // SQL query to retrieve user data
    $query = "SELECT id,Fullname, Category, FbAccount, Twitter, InstaAccount, UserImage, Email, Linkedin, Pinterest, WeChatId, SnapChatUsername, TikTokUsername, Status FROM request WHERE id = ? AND Email = ?";
    $stmt = $conn->prepare($query);

    if ($stmt) {
        $stmt->bind_param("is", $userId, $userEmail);

        if ($stmt->execute()) {
            $stmt->store_result();

            // Assuming your user table has 13 columns (adjust this number based on your actual table structure)
            $expectedColumns = 14;

            if ($stmt->num_rows > 0) {
                $stmt->bind_result($id,
                    $Fullname, $Category, $FbAccount, $Twitter, $InstaAccount, $UserImage, $Email, $Linkedin, $Pinterest, $WeChatId, $SnapChatUsername, $TikTokUsername, $Status
                );

                // Fetch user's data
                $stmt->fetch();

                // Display the user profile section
           echo '<section class="section">';
echo '<div class="container">';
echo '<div class="row align-items-center">';  // Removed justify-content-center to align form and image in the row

// Form on the left side
echo '<div class="col-lg-7">';
echo '<div class="section-title">';
echo '<div id="editProfileForm">';
              echo '<form id="profileForm" method="post" action="' . htmlspecialchars($_SERVER["PHP_SELF"]) . '">';
echo '<div class="form-row">';

// First column
echo '<div class="col-md-6">';
echo '<label for="editFullname">Full Name:</label>';
echo '<input type="text" id="editFullname" name="editFullname" value="' . $Fullname . '" readonly class="editable-field">';
echo '<label for="editCategory">Category:</label>';
echo '<input type="text" id="editCategory" name="editCategory" value="' . $Category . '" readonly class="editable-field">';
echo '<label for="editEmail">Email:</label>';
echo '<input type="text" id="editEmail" name="editEmail" value="' . $Email . '" readonly class="editable-field">';
echo '<label for="editFbAccount">Facebook:</label>';
echo '<input type="text" id="editFbAccount" name="editFbAccount" value="' . $FbAccount . '" readonly class="editable-field">';
echo '<label for="editTwitter">Twitter:</label>';
echo '<input type="text" id="editTwitter" name="editTwitter" value="' . $Twitter . '" readonly class="editable-field">';

echo '</div>';

// Second column
echo '<div class="col-md-6">';

echo '<label for="editLinkedin">LinkedIn:</label>';
echo '<input type="text" id="editLinkedin" name="editLinkedin" value="' . $Linkedin . '" readonly class="editable-field">';
echo '<label for="editInstaAccount">Instagram:</label>';
echo '<input type="text" id="editInstaAccount" name="editInstaAccount" value="' . $InstaAccount . '" readonly class="editable-field">';
echo '<label for="editPinterest">Pinterest:</label>';
echo '<input type="text" id="editPinterest" name="editPinterest" value="' . $Pinterest . '" readonly class="editable-field">';
echo '<label for="editWeChatId">WeChat:</label>';
echo '<input type="text" id="editWeChatId" name="editWeChatId" value="' . $WeChatId . '" readonly class="editable-field">';
echo '<label for="editSnapChatUsername">Snapchat:</label>';
echo '<input type="text" id="editSnapChatUsername" name="editSnapChatUsername" value="' . $SnapChatUsername . '" readonly class="editable-field">';
echo '<label for="editTikTokUsername">TikTok:</label>';
echo '<input type="text" id="editTikTokUsername" name="editTikTokUsername" value="' . $TikTokUsername . '" readonly class="editable-field">';
echo '</div>';

echo '</div>'; // End of form-row

// Update Profile Button
echo '<button type="button" class="btn btn-primary" id="updateProfileBtn">Update Profile</button>';

// Save Changes Button (initially hidden)
echo '<button type="submit" class="btn btn-success" name="saveProfileBtn" id="saveProfileBtn" style="display: none;">Save Changes</button>';
echo '</form>';

echo '</div>';
echo '</div>';
echo '</div>';
echo '<div class="col-lg-5 mt-5 mt-lg-0">';

if ($UserImage !== null) {
    // Convert BLOB data to base64
    $imageData = base64_encode($UserImage);

    // Ensure that the data is a type of image
    $finfo = new finfo(FILEINFO_MIME_TYPE);
    $mimeType = $finfo->buffer($UserImage);

    // Prepare the image source string
    $imageSrc = "data:$mimeType;base64,$imageData";

    // Echo the image element within a frame
    echo '<div style="border: 2px solid #ccc; padding: 10px; position: relative; display: inline-block;">';
    echo '<img id="userImage" loading="lazy" decoding="async" src="' . $imageSrc . '" alt="User Image" class="rounded w-100">';
    echo '<button id="editButton" style="position: absolute; top: 5px; right: 5px; cursor: pointer;">Edit</button>';
    echo '</div>';
    // File input for choosing a new image (hidden initially)
    echo '<input type="file" id="fileInput" style="display: none;">';
    // Save button (hidden initially)
    echo '<button id="saveButton" style="display: none;">Save</button>';
    // Assuming you have an 'id' value; replace 'your_id_value' with the actual value
  
    echo '        <input type="hidden" id="recordId" value="$id">';
} else {
    echo 'No image found.';
}

echo '</div>';
echo '</div>';
echo '</section>';
            } else {
                echo "User not found.";
            }
        } else {
            // Handle statement execution error
            echo "Error: " . $stmt->error;
        }

        // Close the statement
        $stmt->close();
    } else {
        // Handle prepared statement error
        echo "Error in statement preparation: " . $conn->error;
    }
} else {
    echo "Invalid user ID.";
}

// Your existing code for establishing database connection and retrieving user data

// Check if the form is submitted for update
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["saveProfileBtn"])) {
    // Get updated data from the form
   $updatedFullname = $_POST['editFullname'];
    $updatedCategory = $_POST['editCategory'];
    $updatedFbAccount = $_POST['editFbAccount'];
    $updatedTwitter = $_POST['editTwitter'];
    $updatedInstaAccount = $_POST['editInstaAccount'];
    $updatedLinkedin = $_POST['editLinkedin'];
    $updatedPinterest = $_POST['editPinterest'];
    $updatedWeChatId = $_POST['editWeChatId'];
    $updatedSnapChatUsername = $_POST['editSnapChatUsername'];
    $updatedTikTokUsername = $_POST['editTikTokUsername'];

    // ... Repeat similar lines for other input fields

    // Prepare and execute the update statement
    $updateStmt = $conn->prepare("UPDATE request SET 
        Fullname=?, 
        Category=?, 
        FbAccount=?, 
        Twitter=?, 
        InstaAccount=?, 
        Linkedin=?, 
        Pinterest=?, 
        WeChatId=?, 
        SnapChatUsername=?, 
        TikTokUsername=?
        WHERE id=?");

    // Bind parameters using "sssssssssss"
    $updateStmt->bind_param("sssssssssss", 
        $updatedFullname, 
        $updatedCategory, 
        $updatedFbAccount, 
        $updatedTwitter, 
        $updatedInstaAccount, 
        $updatedLinkedin, 
        $updatedPinterest, 
        $updatedWeChatId, 
        $updatedSnapChatUsername, 
        $updatedTikTokUsername, 
        $userId);

if ($updateStmt->execute()) {
    // Update successful

    // Close the update statement
    $updateStmt->close();

    // Set a session variable to indicate that data has been saved
    $_SESSION['data_saved'] = true;

    // Check if the session variable is not set (first time reloading)
    if (!isset($_SESSION['reloadOnce'])) {
        // Set the session variable to indicate that reloading has occurred
        $_SESSION['reloadOnce'] = true;

        // Reload the current page with JavaScript
        echo '<script>
            window.location.reload();
        </script>';
        exit(); // Ensure that no further code is executed after the reload
    }
} else {
    // Update failed
    echo "Error updating data: " . $updateStmt->error;
}



}

// Continue with the rest of your HTML code
?><!-- Your existing HTML and PHP code -->

<script>
        $(document).ready(function() {
            // Show the file input when the edit button is clicked
            $('#editButton').click(function() {
                $('#fileInput').click();
            });

            // Handle file input change
            $('#fileInput').change(function() {
                // Show the save button after selecting a new image
                $('#saveButton').show();
            });

            // Handle save button click
            $('#saveButton').click(function() {
                // Get the file input
                var fileInput = $('#fileInput')[0];
                
                if (fileInput.files.length > 0) {
                    // Use FormData to handle file uploads
                    var formData = new FormData();
                    formData.append('image', fileInput.files[0]);
                    formData.append('id', $('#recordId').val());

                    // Send the data to the server using Ajax
                    $.ajax({
                        type: 'POST',
                        url: 'update_image.php',
                        data: formData,
                        contentType: false,
                        processData: false,
                        success: function(response) {
                            // Handle the server response (e.g., show a success message)
                            console.log(response);
                        },
                        error: function(xhr, status, error) {
                            // Handle errors
                            console.error(xhr.responseText);
                        }
                    });
                }
            });
        });
    </script>

<script>
document.addEventListener("DOMContentLoaded", function () {
    var editProfileForm = document.getElementById("profileForm");
    var updateProfileBtn = document.getElementById("updateProfileBtn");

    // Add event listener to "Update Profile" button
    updateProfileBtn.addEventListener("click", function () {
        // Enable form fields for editing
        enableFormFields(true);
    });

    // Function to enable/disable form fields
    function enableFormFields(enable) {
        var formFields = editProfileForm.elements;
        for (var i = 0; i < formFields.length; i++) {
            formFields[i].readOnly = !enable;
        }

        // Toggle visibility of buttons
        document.getElementById("updateProfileBtn").style.display = enable ? "none" : "block";
        document.getElementById("saveProfileBtn").style.display = enable ? "block" : "none";
    }

    // Add event listener to the form for submission
    editProfileForm.addEventListener("submit", function (event) {
        // Ensure that the form is submitted via a traditional POST request
        // (not using AJAX) to allow the page to refresh after submission
        editProfileForm.setAttribute("action", window.location.href);
        editProfileForm.setAttribute("method", "post");

        // Enable form fields for submission
        enableFormFields(true);
    });
});
</script>

    
    </main><!-- End #main -->                               
 <!-- ======= Footer ======= -->
  <footer id="footer" class="footer">

    <div class="footer-newsletter">
      <div class="container">
        <div class="row justify-content-center">
          <div class="col-lg-12 text-center">
            <h4>Legal Support PDMC</h4>
            <p>"Your creative journey is safeguarded with PDMC's commitment to providing free legal coverage. Partnered with top law firms, we ensure that our members can express themselves freely without fear of persecution. Explore the legal support available to you as a valued member of the PDMC community."</p>
          </div>
        
        </div>
      </div>
    </div>

    <div class="footer-top">
      <div class="container">
        <div class="row gy-4">
          <div class="col-lg-4 col-md-12 footer-info">
            <a href="index.html" class="logo d-flex align-items-center">
              <img src="assets/img/logo.png" alt="">
              <span>PDMC</span>
            </a>
            <p>Cras fermentum odio eu feugiat lide par naso tierra. Justo eget nada terra videa magna derita valies darta donna mare fermentum iaculis eu non diam phasellus.</p>
            <div class="social-links mt-3">
              <a href="#" class="twitter"><i class="bi bi-twitter"></i></a>
              <a href="#" class="facebook"><i class="bi bi-facebook"></i></a>
              <a href="#" class="instagram"><i class="bi bi-instagram"></i></a>
              <a href="#" class="linkedin"><i class="bi bi-linkedin"></i></a>
            </div>
          </div>

          <div class="col-lg-2 col-6 footer-links">
            <h4>Useful Links</h4>
            <ul>
              <li><i class="bi bi-chevron-right"></i> <a href="#">Home</a></li>
              <li><i class="bi bi-chevron-right"></i> <a href="#">About us</a></li>
              <li><i class="bi bi-chevron-right"></i> <a href="#recent-blog-posts">Blogs</a></li>
         
            </ul>
          </div>

          <div class="col-lg-3 col-6 footer-links">
            <h4>Our Services</h4>
            <ul>
              <li><i class="bi bi-chevron-right"></i> <a href="membership.php">Membership</a></li>
              <li><i class="bi bi-chevron-right"></i> <a href="pdmc-member.php">PDMC Member</li>
              <li><i class="bi bi-chevron-right"></i> <a href="becomemember.php">Become Member</a></li>
            </ul>
          </div>

          <div class="col-lg-3 col-md-12 footer-contact text-center text-md-start">
            <h4>Contact Us</h4>
            <p>
             
              <strong>Phone:</strong> +1 5589 55488 55<br>
              <strong>Email:</strong> info@example.com<br>
            </p>

          </div>

        </div>
      </div>
    </div>

    <div class="container">
      <div class="copyright">
        &copy; Copyright <strong><span>PDMC</span></strong>. All Rights Reserved
      </div>
      <div class="credits">
      
        Designed by <a href="https://epicinfotechconsulting.com/">Epic Infotech Consulting Group</a>
      </div>
    </div>
  </footer><!-- End Footer -->

  <a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>

  <!-- Vendor JS Files -->
  <script src="assets/vendor/purecounter/purecounter_vanilla.js"></script>
  <script src="assets/vendor/aos/aos.js"></script>
  <script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <script src="assets/vendor/glightbox/js/glightbox.min.js"></script>
  <script src="assets/vendor/isotope-layout/isotope.pkgd.min.js"></script>
  <script src="assets/vendor/swiper/swiper-bundle.min.js"></script>
  <script src="assets/vendor/php-email-form/validate.js"></script>

  <!-- Template Main JS File -->
  <script src="assets/js/main.js"></script>
</body>

</html>