Domain: amberpublishers.in
Server Adress: 86.38.243.169

privdayz.com

/home/u866425823/domains/amberpublishers.in/public_html/admin/
Dosya Yükle :
Current File : /home/u866425823/domains/amberpublishers.in/public_html/admin/updateeditor.php

<?php
session_start();
require 'include/PHPHelper.php';
if (!isset($_SESSION['userID'])) {
    header("location: login.php");
    exit(); // Add exit to stop further execution
} else {
    if (isset($_POST['submit'])) {
        // Get the editor ID from the URL
        $editorID = $_GET['id'];

        // Get the updated editor details from the form
        $name = $_POST['name'];
        $designation = $_POST['designation'];
        $department = $_POST['department'];
        $email = $_POST['email'];
        $profile = $_POST['profile_link'];
        $institute = $_POST['institute'];
        $category = $_POST['category'];

        // Check if a new photo is uploaded
        if ($_FILES['photo']['size'] > 0) {
            $photo = $_FILES['photo']['name'];
            $photo_temp = $_FILES['photo']['tmp_name'];

            $target_dir = "../assets/img/editors/";
            $target_file = $target_dir . basename($photo);
            $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));

            // Check if the file is a valid image
            $check = getimagesize($photo_temp);
            if ($check !== false) {
                // Allow only certain file formats
                if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
                    header("Location: updateeditor.php?id=$editorID&error=3");
                    exit();
                }

                // Move the uploaded file to the target directory
                if (move_uploaded_file($photo_temp, $target_file)) {
                    // Update the editor details with the new photo
                    $sql = "UPDATE editorial_board SET name=?, designation=?, department=?, email=?, profile_link=?, institute=?, photo=?, category=? WHERE id=?";
                    $stmt = mysqli_prepare($conn, $sql);
                    mysqli_stmt_bind_param($stmt, "ssssssssi", $name, $designation, $department, $email, $profile, $institute, $photo, $category, $editorID);
                    mysqli_stmt_execute($stmt);
                    mysqli_stmt_close($stmt);
                } else {
                    header("Location: updateeditor.php?id=$editorID&error=4");
                    exit();
                }
            } else {
                header("Location: updateeditor.php?id=$editorID&error=5");
                exit();
            }
        } else {
            // Update the editor details without changing the photo
            $sql = "UPDATE editorial_board SET name=?, designation=?, department=?, email=?, profile_link=?, institute=?, category=? WHERE id=?";
            $stmt = mysqli_prepare($conn, $sql);
            mysqli_stmt_bind_param($stmt, "sssssssi", $name, $designation, $department, $email, $profile, $institute, $category, $editorID);
            mysqli_stmt_execute($stmt);
            mysqli_stmt_close($stmt);
        }

        header("Location: editeditor.php");
        exit();
    } else {
        // Retrieve the editor details from the database based on the ID
        if (isset($_GET['id'])) {
            $editorID = $_GET['id'];
            $query = "SELECT * FROM editorial_board WHERE id = ?";
            $stmt = mysqli_prepare($conn, $query);
            mysqli_stmt_bind_param($stmt, "i", $editorID);
            mysqli_stmt_execute($stmt);
            $result = mysqli_stmt_get_result($stmt);
            $editor = mysqli_fetch_assoc($result);
            mysqli_stmt_close($stmt);
            mysqli_close($conn);
        } else {
            header("Location: editeditor.php");
            exit();
        }
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<?php
$title = "Update Editor || Amber Publishers";
include 'include/head.php';
?>

<body>
    <!-- ======= Header ======= -->
    <?php include 'include/header.php'; ?>
    <!-- End Header -->

    <!-- ======= Sidebar ======= -->
    <?php include 'include/sidebar.php'; ?>
    <!-- End Sidebar -->

    <main id="main" class="main">
        <div class="pagetitle">
            <h1>Update Editor</h1>
            <nav>
                <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="index.php">IJSRI Dashboard</a></li>
                    <li class="breadcrumb-item"><a href="editors.php">Edit Editors Details</a></li>
                    <li class="breadcrumb-item active">Update Editor</li>
                </ol>
            </nav>
        </div><!-- End Page Title -->

        <section class="section">
            <div class="row">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-body">
                            <div class="card-title">
                                <h5>Update Editor</h5>
                                <div class="form">
                                    <form method="POST" action="updateeditor.php?id=<?php echo $editor['id']; ?>" enctype="multipart/form-data">
                                        <div class="row mb-3">
                                            <label for="name" class="col-md-4 col-lg-3 col-form-label">Name:</label>
                                            <div class="col-md-8 col-lg-9">
                                                <input name="name" type="text" class="form-control" id="name" value="<?php echo $editor['name']; ?>" required>
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <label for="designation" class="col-md-4 col-lg-3 col-form-label">Designation:</label>
                                            <div class="col-md-8 col-lg-9">
                                                <input name="designation" type="text" class="form-control" id="designation" value="<?php echo $editor['designation']; ?>" required>
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <label for="category" class="col-md-4 col-lg-3 col-form-label">Category:</label>
                                            <div class="col-md-8 col-lg-9">
                                                <select name="category" class="form-control" id="category" required>
                                                    <option value="" disabled>Select Category</option>
                                                    <option value="Chief Editor" <?php echo ($editor['category'] == 'Chief Editor') ? 'selected' : ''; ?>>Chief Editor</option>
                                                    <option value="Associate Editor" <?php echo ($editor['category'] == 'Associate Editor') ? 'selected' : ''; ?>>Associate Editor</option>
                                                    <option value="Executive Editor" <?php echo ($editor['category'] == 'Executive Editor') ? 'selected' : ''; ?>>Executive Editor</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <label for="department" class="col-md-4 col-lg-3 col-form-label">Department:</label>
                                            <div class="col-md-8 col-lg-9">
                                                <input name="department" type="text" class="form-control" id="department" value="<?php echo $editor['department']; ?>" required>
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <label for="email" class="col-md-4 col-lg-3 col-form-label">Email:</label>
                                            <div class="col-md-8 col-lg-9">
                                                <input name="email" type="email" class="form-control" id="email" value="<?php echo $editor['email']; ?>" required>
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <label for="profile_link" class="col-md-4 col-lg-3 col-form-label">Profile Link:</label>
                                            <div class="col-md-8 col-lg-9">
                                                <input name="profile_link" type="text" class="form-control" id="profile_link" value="<?php echo $editor['profile_link']; ?>" required>
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <label for="institute" class="col-md-4 col-lg-3 col-form-label">Institute:</label>
                                            <div class="col-md-8 col-lg-9">
                                                <input name="institute" type="text" class="form-control" id="institute" value="<?php echo $editor['institute']; ?>" required>
                                            </div>
                                        </div>
                                        <div class="row mb-3">
                                            <label for="photo" class="col-md-4 col-lg-3 col-form-label">Photograph:</label>
                                            <div class="col-md-8 col-lg-9">
                                                <input name="photo" type="file" class="form-control" id="photo">
                                                <p class="form-text">Upload a new photograph if you want to update it.</p>
                                            </div>
                                        </div>

                                        <div class="row mt-3">
                                            <div class="text-center">
                                                <input type="submit" name="submit" id="submit" class="btn btn-primary col-lg-12" value="Update Editor">
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main><!-- End #main -->

    <!-- ======= Footer ======= -->
    <?php include 'include/footer.php'; ?>

</body>

</html>


coded by Privdayz.com - Visit https://privdayz.com/ for more php shells.