D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
u384067285
/
domains
/
cauldronsisterss.com
/
public_html
/
admin
/
Filename :
media.php
back
Copy
<?php session_start(); // Use strict error reporting during development error_reporting(E_ALL); ini_set('display_errors', 1); // Include the database connection include 'connection.php'; // Check if the session variable is set and redirect if not if (empty($_SESSION['bpmsaid'])) { header("Location: logout.php"); exit(); } $msg = ""; if (isset($_POST['add'])) { // Validate and sanitize inputs $upload_date = trim($_POST['upload_date']); $media_name = trim($_POST['media_name']); $aLink = filter_var(trim($_POST['aLink']), FILTER_SANITIZE_URL); if (empty($upload_date) || empty($media_name)) { $msg = "Please fill in all required fields."; } else { // File Upload Validation if (isset($_FILES["image1"]) && $_FILES["image1"]["error"] === UPLOAD_ERR_OK) { $filename = $_FILES["image1"]["name"]; $tempname = $_FILES["image1"]["tmp_name"]; $folder = "images/media/" . basename($filename); $allowedExtensions = ["jpg", "jpeg", "png", "gif"]; $fileExtension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if (in_array($fileExtension, $allowedExtensions)) { // Prepared statement for inserting data $sql = "INSERT INTO tblmediacoverage (upload_date, media_name, image1, aLink) VALUES (?, ?, ?, ?)"; $stmt = $conn->prepare($sql); $stmt->bind_param("ssss", $upload_date, $media_name, $filename, $aLink); if ($stmt->execute()) { move_uploaded_file($tempname, $folder); $msg = "Media uploaded successfully."; } else { $msg = "Error: " . $stmt->error; } $stmt->close(); } else { $msg = "Invalid file type. Allowed types: jpg, jpeg, png, gif."; } } else { $msg = "File upload error: " . ($_FILES["image1"]["error"] ?? "Unknown error"); } } } ?> <!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Cauldron Sisterss | Media Coverage</title> <!-- plugins:css --> <link rel="stylesheet" href="vendors/feather/feather.css"> <link rel="stylesheet" href="vendors/mdi/css/materialdesignicons.min.css"> <link rel="stylesheet" href="vendors/ti-icons/css/themify-icons.css"> <link rel="stylesheet" href="vendors/typicons/typicons.css"> <link rel="stylesheet" href="vendors/simple-line-icons/css/simple-line-icons.css"> <link rel="stylesheet" href="vendors/css/vendor.bundle.base.css"> <!-- endinject --> <!-- Plugin css for this page --> <link rel="stylesheet" href="vendors/select2/select2.min.css"> <link rel="stylesheet" href="vendors/select2-bootstrap-theme/select2-bootstrap.min.css"> <!-- End plugin css for this page --> <!-- inject:css --> <link rel="stylesheet" href="css/vertical-layout-light/style.css"> <!-- endinject --> <?php include 'favicon.php'; ?> </head> <body> <div class="container-scroller"> <!-- partial:../../partials/_navbar.php --> <?php include 'header.php'; ?> <!-- partial --> <div class="container-fluid page-body-wrapper"> <!-- partial:../../partials/_sidebar.html --> <?php include 'sidebar.php'; ?> <!-- partial --> <div class="main-panel"> <div class="content-wrapper"> <div class="row"> <div class="col-md-12 grid-margin stretch-card"> <div class="card"> <div class="card-body"> <h4 class="card-title">Add Media Coverage Images <span style = "color:red;"> <?php echo $msg; ?> </span> </h4> <form class="forms-sample" method="post" enctype="multipart/form-data"> <div class="form-group col-lg-6"> <label for="name">Name</label> <input type="text" class="form-control" id="name" placeholder="Name" name="media_name" required> </div> <div class="form-group col-lg-6"> <label for="name">Source Link</label> <textarea class = "form-control" placeholder = "Paste Source Link" name = "aLink"></textarea> </div> <div class="form-group col-lg-6"> <label for="image1">Date</label> <input type = "date" class="form-control" name = "upload_date" required> </div> <div class="form-group col-lg-6"> <label for="image1">Image1</label> <input type = "file" class="form-control" name = "image1"> </div> <button type="submit" class="btn btn-primary me-2" name="add">Add</button> </form> </div> </div> </div> </div> <!-- Manage Company Contact --> <div class="row"> <div class="col-lg-12 grid-margin stretch-card"> <div class="card"> <div class="card-body"> <h4 class="card-title">Manage Media Coverage </h4> <div class="table-responsive"> <table class="table table-hover"> <thead> <tr> <th>Date</th> <th>Image</th> <th>Name</th> <th>Action</th> </tr> </thead> <tbody> <?php $sql = "SELECT * FROM tblmediacoverage ORDER BY upload_date DESC LIMIT 20"; $result = $conn->query($sql); while ($row = mysqli_fetch_array($result)) { ?> <tr class="d-flex"> <td><?php echo $row['upload_date']; ?></td> <td> <img src="images/media/<?php echo $row['image1']; ?>" alt="<?php echo $row['image1']; ?>"> </td> <td><?php echo $row['media_name']; ?></td> <td> <label class="badge badge-warning"> <a href = "edit_media.php?editid=<?php echo $row['id']; ?>" style="text-decoration:none; color:black;">Edit</a> </label> <label class="badge badge-danger"> <a href = "delete_media.php?id=<?php echo $row['id']; ?>" style="text-decoration:none; color:black;">Delete</a> </label> </td> </tr> <?php } ?> </tbody> </table> </div> </div> </div> </div> </div> </div> <!-- content-wrapper ends --> <!-- partial:../../partials/_footer.html --> <?php include 'footer.php'; ?> <!-- partial --> </div> <!-- main-panel ends --> </div> <!-- page-body-wrapper ends --> </div> <!-- container-scroller --> <!-- plugins:js --> <script src="vendors/js/vendor.bundle.base.js"></script> <!-- endinject --> <!-- Plugin js for this page --> <script src="vendors/typeahead.js/typeahead.bundle.min.js"></script> <script src="vendors/select2/select2.min.js"></script> <script src="vendors/bootstrap-datepicker/bootstrap-datepicker.min.js"></script> <!-- End plugin js for this page --> <!-- inject:js --> <script src="js/off-canvas.js"></script> <script src="js/hoverable-collapse.js"></script> <script src="js/template.js"></script> <script src="js/settings.js"></script> <script src="js/todolist.js"></script> <!-- endinject --> <!-- Custom js for this page--> <script src="js/file-upload.js"></script> <script src="js/typeahead.js"></script> <script src="js/select2.js"></script> <!-- End custom js for this page--> </body> </html>