D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
public_html
/
encoadminders
/
Filename :
add_showcase.php
back
Copy
<?php session_start(); include 'config.php'; if (!isset($_SESSION['admin_name'])) { echo '<script>window.location.href = "login.php";</script>'; exit; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $title = mysqli_real_escape_string($conn, $_POST['title']); $link = mysqli_real_escape_string($conn, $_POST['link']); if (isset($_FILES['image']['name']) && $_FILES['image']['name'] != '') { $image_name = time() . '_' . $_FILES['image']['name']; $upload_dir = 'uploads/showcase/'; $upload_file = $upload_dir . basename($image_name); if (!file_exists($upload_dir)) { mkdir($upload_dir, 0777, true); } if (move_uploaded_file($_FILES['image']['tmp_name'], $upload_file)) { $sql = "INSERT INTO showcase (title, image, link) VALUES ('$title', '$image_name', '$link')"; if (mysqli_query($conn, $sql)) { $success = "Showcase image added successfully."; } else { $error = "Database error: " . mysqli_error($conn); } } else { $error = "Error uploading the image."; } } else { $error = "Please select an image to upload."; } } ?> <!DOCTYPE html> <html lang="en"> <head> <?php require('style.php'); ?> <title>Add Showcase Image</title> <style> @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap'); body { background: linear-gradient(120deg, #6a11cb, #2575fc); font-family: 'Poppins', sans-serif; margin: 0; padding: 0; min-height: 100vh; } .container { max-width: 500px; width: 100%; background: #fff; border-radius: 15px; padding: 25px 30px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2); position: relative; } .container h1 { text-align: center; font-size: 24px; font-weight: 600; color: #444; margin-bottom: 25px; } .form-group { margin-bottom: 20px; } .form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 8px; color: #555; } .form-control { width: 100%; height: 45px; border: 1px solid #ddd; border-radius: 8px; padding: 0 15px; font-size: 14px; color: #555; outline: none; transition: border 0.3s; } .form-control:focus { border: 1px solid #2575fc; } .form-group input[type="file"] { padding: 5px; } .btn-primary { width: 100%; height: 45px; background: linear-gradient(90deg, #6a11cb, #2575fc); border: none; border-radius: 8px; color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; transition: transform 0.3s, box-shadow 0.3s; } .btn-primary:hover { transform: translateY(-3px); box-shadow: 0 8px 15px rgba(106, 17, 203, 0.3); } .alert { padding: 12px; border-radius: 8px; margin-bottom: 15px; font-size: 14px; } .alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; } .alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; } .form-container { animation: fadeInUp 0.8s ease-in-out; } @keyframes fadeInUp { 0% { opacity: 0; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } } </style> </head> <body> <?php include('sidebar.php') ?> <div class="home-container"> <div class="container form-container"> <h1>Add Gallery Image</h1> <?php if (isset($success)) : ?> <div class="alert alert-success"><?= $success ?></div> <?php endif; ?> <?php if (isset($error)) : ?> <div class="alert alert-danger"><?= $error ?></div> <?php endif; ?> <form action="" method="POST" enctype="multipart/form-data"> <div class="form-group"> <label for="title">Image Title</label> <input type="text" name="title" id="title" class="form-control" placeholder="Enter image title" required> </div> <div class="form-group"> <label for="image">Image</label> <input type="file" name="image" id="image" class="form-control" accept="image/*" required> </div> <div class="form-group"> <label for="link">Image Link</label> <input type="text" name="link" id="link" class="form-control" placeholder="https://example.com" required> </div> <button type="submit" class="btn-primary">Add Showcase</button> </form> </div> <?php include('footer.php') ?> </div> </body> </html>