PHP 8.5.2
Preview: header-changes.php Size: 7.83 KB
/home/serveshikshafoundation/htdocs/serveshikshafoundation.org.in/admin/html/header-changes.php

<?php
include('auth.php');
include('connection.php');
?>


<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Admin</title>
  <link rel="shortcut icon" type="image/png" href="../assets/images/logos/favicon.png" />
  <link rel="stylesheet" href="../assets/css/styles.min.css" />
</head>

<body>
  <!--  Body Wrapper -->
  <div class="page-wrapper" id="main-wrapper" data-layout="vertical" data-navbarbg="skin6" data-sidebartype="full"
    data-sidebar-position="fixed" data-header-position="fixed">
    <!-- Sidebar Start -->
    <?php include('aside.php') ?>
    <!--  Sidebar End -->
    <!--  Main wrapper -->
    <div class="body-wrapper">
      <!--  Header Start -->
      <?php include('header.php') ?>
      <!--  Header End -->
      <div class="container-fluid">
      <div class="container-fluid">
    <?php

    // Fetch existing contact details
    $query = "SELECT * FROM contact_info WHERE id = 1";
    $result = mysqli_query($conn, $query);
    $data = mysqli_fetch_assoc($result);

    // Handle Contact Info Update
    if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['update_contact'])) {
        $address = mysqli_real_escape_string($conn, $_POST['address']);
        $phone = mysqli_real_escape_string($conn, $_POST['phone']);
        $email1 = mysqli_real_escape_string($conn, $_POST['email1']);
        $email2 = mysqli_real_escape_string($conn, $_POST['email2']);
        $facebook = mysqli_real_escape_string($conn, $_POST['facebook']);
        $instagram = mysqli_real_escape_string($conn, $_POST['instagram']);
        // $pinterest = mysqli_real_escape_string($conn, $_POST['pinterest']);
        $twitter = mysqli_real_escape_string($conn, $_POST['twitter']);
        $whatsapp = mysqli_real_escape_string($conn, $_POST['whatsapp']);
        $updateQuery = "UPDATE contact_info SET 
                        address = '$address', 
                        phone = '$phone',
                        email1 = '$email1',
                        email2 =  '$email2', 
                        facebook = '$facebook', 
                        instagram = '$instagram',
                        twitter = '$twitter',
                        whatsapp = '$whatsapp'
                        WHERE id = 1";

        if (mysqli_query($conn, $updateQuery)) {
            echo "<script>alert('Contact details updated successfully!'); window.location.href='header-changes.php';</script>";
        } else {
            echo "Error updating record: " . mysqli_error($conn);
        }
    }

    // Handle Logo Upload
    if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['update_logo'])) {
        $targetDir = "assets/img/logo/";
        if (!file_exists($targetDir)) {
            mkdir($targetDir, 0777, true); // Create directory if not exists
        }

        if (!isset($_FILES["logo"]) || $_FILES["logo"]["error"] !== UPLOAD_ERR_OK) {
            die("<script>alert('File upload error: " . $_FILES["logo"]["error"] . "');</script>");
        }

        $fileName = basename($_FILES["logo"]["name"]);
        $targetFile = $targetDir . $fileName;
        $imageFileType = strtolower(pathinfo($targetFile, PATHINFO_EXTENSION));

        // Allowed file formats
        $allowedFormats = ["jpg", "jpeg", "png", "gif"];
        if (!in_array($imageFileType, $allowedFormats)) {
            die("<script>alert('Only JPG, JPEG, PNG & GIF files are allowed.');</script>");
        }

        // Check if the file is a real image
        $check = getimagesize($_FILES["logo"]["tmp_name"]);
        if ($check === false) {
            die("<script>alert('File is not a valid image.');</script>");
        }

        // Move the uploaded file to the destination folder
        if (move_uploaded_file($_FILES["logo"]["tmp_name"], $targetFile)) {
            // Update logo path in database
            $updateQuery = "UPDATE contact_info SET logo = '$targetFile' WHERE id = 1";
            if (mysqli_query($conn, $updateQuery)) {
                echo "<script>alert('Logo updated successfully!'); window.location.href='header-changes.php';</script>";
            } else {
                echo "<script>alert('Database update failed!');</script>";
            }
        } else {
            echo "<script>alert('Error uploading file. Check folder permissions.');</script>";
        }
    }
    ?>

    <h2 class="mb-4">Update Contact Information</h2>
    <form method="POST" action="">
        <input type="hidden" name="update_contact" value="1">
        <div class="mb-3">
            <label class="form-label">Address</label>
            <input type="text" name="address" class="form-control" value="<?php echo htmlspecialchars($data['address']); ?>" required>
        </div>
        <div class="mb-3">
            <label class="form-label">Phone</label>
            <input type="text" name="phone" class="form-control" value="<?php echo htmlspecialchars($data['phone']); ?>" required>
        </div>
        <div class="mb-3">
            <label class="form-label">Email1</label>
            <input type="email" name="email1" class="form-control" value="<?php echo htmlspecialchars($data['email1']); ?>" required>
        </div>
        <div class="mb-3">
            <label class="form-label">Email2</label>
            <input type="email" name="email2" class="form-control" value="<?php echo htmlspecialchars($data['email2']); ?>" required>
        </div>
        <div class="mb-3">
            <label class="form-label">Facebook URL</label>
            <input type="text" name="facebook" class="form-control" value="<?php echo htmlspecialchars($data['facebook']); ?>">
        </div>
        <div class="mb-3">
            <label class="form-label">Instagram URL</label>
            <input type="text" name="instagram" class="form-control" value="<?php echo htmlspecialchars($data['instagram']); ?>">
        </div>
        <!-- <div class="mb-3">
            <label class="form-label">Pinterest URL</label>
            <input type="text" name="pinterest" class="form-control" value="<?php echo htmlspecialchars($data['pinterest']); ?>">
        </div> -->
        <div class="mb-3">
            <label class="form-label">Twitter URL</label>
            <input type="text" name="twitter" class="form-control" value="<?php echo htmlspecialchars($data['twitter']); ?>">
        </div>
        <div class="mb-3">
            <label class="form-label">Whatsapp</label>
            <input type="text" name="whatsapp" class="form-control" value="<?php echo htmlspecialchars($data['whatsapp']); ?>">
        </div>
        <button type="submit" class="btn btn-primary">Update Details</button>
    </form>

    <div class="container mt-5">
        <h2>Update Logo</h2>
        <form method="POST" action="" enctype="multipart/form-data">
            <input type="hidden" name="update_logo" value="1">
            <div class="mb-3">
                <label class="form-label">Current Logo</label><br>
                <img src="<?php echo htmlspecialchars($data['logo']); ?>" style="width:150px;">
            </div>
            <div class="mb-3">
                <label class="form-label">Upload New Logo</label>
                <input type="file" name="logo" class="form-control" required>
            </div>
            <button type="submit" class="btn btn-primary">Update Logo</button>
        </form>
    </div>
</div>

      </div>
      <!-- Table -->




    </div>
  </div>


  <script src="../assets/libs/jquery/dist/jquery.min.js"></script>
  <script src="../assets/libs/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
  <script src="../assets/js/sidebarmenu.js"></script>
  <script src="../assets/js/app.min.js"></script>
  <script src="../assets/libs/simplebar/dist/simplebar.js"></script>
</body>

</html>

Directory Contents

Dirs: 11 × Files: 30

Name Size Perms Modified Actions
- drwxr-xr-x 2025-04-05 16:58:42
Edit Download
assets DIR
- drwxr-xr-x 2025-04-05 16:58:42
Edit Download
baby-dec DIR
- drwxr-xr-x 2025-04-05 16:58:42
Edit Download
- drwxr-xr-x 2025-04-05 16:58:42
Edit Download
- drwxr-xr-x 2025-04-05 16:58:44
Edit Download
- drwxr-xr-x 2025-04-05 16:58:44
Edit Download
- drwxr-xr-x 2025-04-05 16:58:44
Edit Download
- drwxr-xr-x 2025-04-05 16:58:44
Edit Download
- drwxr-xr-x 2025-04-05 16:58:44
Edit Download
- drwxr-xr-x 2025-04-05 16:58:46
Edit Download
- drwxr-xr-x 2025-04-05 16:58:46
Edit Download
8.63 KB lrw-r----- 2025-04-06 01:10:32
Edit Download
8.49 KB lrw-r----- 2025-04-05 20:17:06
Edit Download
8.33 KB lrw-r----- 2025-04-01 18:04:14
Edit Download
4.67 KB lrw-r----- 2025-07-01 06:02:29
Edit Download
6.91 KB lrw-r----- 2025-04-07 09:05:32
Edit Download
4.59 KB lrw-r----- 2025-07-01 06:36:30
Edit Download
164 B lrw-r----- 2025-04-05 17:07:44
Edit Download
471 B lrw-r----- 2026-04-07 07:13:01
Edit Download
4.07 KB lrw-r----- 2025-04-07 18:20:40
Edit Download
1.62 KB lrw-r----- 2025-03-31 20:18:28
Edit Download
1.92 KB lrw-r----- 2025-04-01 00:02:56
Edit Download
1.93 KB lrw-r----- 2025-04-01 18:10:28
Edit Download
1.20 KB lrw-r----- 2025-04-02 21:38:00
Edit Download
1.94 KB lrw-r----- 2025-04-06 00:58:20
Edit Download
1.62 KB lrw-r----- 2025-07-01 06:05:36
Edit Download
1.67 KB lrw-r----- 2025-03-31 21:50:12
Edit Download
3.15 KB lrw-r----- 2025-04-02 22:26:14
Edit Download
5.43 KB lrw-r----- 2025-04-22 13:05:58
Edit Download
6.16 KB lrw-r----- 2025-04-05 20:16:08
Edit Download
6.18 KB lrw-r----- 2025-04-02 20:43:44
Edit Download
5.88 KB lrw-r----- 2025-04-02 21:46:38
Edit Download
3.17 KB lrw-r----- 2025-07-01 06:17:56
Edit Download
4.14 KB lrw-r----- 2025-03-31 22:30:04
Edit Download
551.14 KB lrw-r--r-- 2025-03-29 19:52:38
Edit Download
3.14 KB lrw-r----- 2025-06-28 23:18:18
Edit Download
4.67 KB lrw-r----- 2025-04-02 22:16:18
Edit Download
7.83 KB lrw-r----- 2025-04-05 23:49:56
Edit Download
3.15 KB lrw-r----- 2025-04-07 18:21:46
Edit Download
120 B lrw-r----- 2024-07-06 23:58:34
Edit Download
5.12 KB lrw-r----- 2025-03-31 22:33:26
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).