📁 File Manager
Editing:
/home/wvl7mof7402e/www/wingstourandtravels.com/admin/add-package.php
<?php // admin/add-package.php require_once '../db_config.php'; /** @var mysqli $conn */ $msg = ""; if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit_package'])) { $category = mysqli_real_escape_string($conn, $_POST['category']); $package_title = mysqli_real_escape_string($conn, $_POST['package_title']); $slug = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $package_title))); $amount = floatval($_POST['amount']); $duration = mysqli_real_escape_string($conn, $_POST['duration']); $overview = mysqli_real_escape_string($conn, $_POST['overview']); $inclusions = mysqli_real_escape_string($conn, $_POST['inclusions']); $exclusions = mysqli_real_escape_string($conn, $_POST['exclusions']); // Image Upload Process $image = ""; if (isset($_FILES['package_image']['name']) && $_FILES['package_image']['name'] != "") { $target_dir = "../assents/images/"; // Check if directory exists, if not create it if (!is_dir($target_dir)) { mkdir($target_dir, 0777, true); } $image = time() . '_' . basename($_FILES["package_image"]["name"]); move_uploaded_file($_FILES["package_image"]["tmp_name"], $target_dir . $image); } $stmt = $conn->prepare("INSERT INTO packages (category, package_title, slug, amount, duration, overview, inclusions, exclusions, image) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->bind_param("sssdsssss", $category, $package_title, $slug, $amount, $duration, $overview, $inclusions, $exclusions, $image); if ($stmt->execute()) { $msg = "Package successfully uploaded!"; } else { $msg = "Error uploading package: " . $conn->error; } } ?> <!DOCTYPE html> <html> <head> <title>Add New Package - Admin</title> <style> .admin-form { max-width: 600px; margin: 30px auto; font-family: sans-serif; background: #ffffff; padding: 25px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); } .form-group { margin-bottom: 15px; } .form-group label { display: block; font-weight: bold; margin-bottom: 5px; color: #0F172A; } .form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px; box-sizing: border-box; border: 1px solid #CBD5E1; border-radius: 6px; } .btn-submit { background: #0b1726; color: #fff; padding: 12px 20px; border: none; cursor: pointer; font-size: 16px; border-radius: 6px; width: 100%; } .msg-box { margin-bottom: 15px; padding: 10px; background: #DCFCE7; color: #166534; border-radius: 6px; } /* ===== Premium Responsive UI — layout only, PHP/logic unchanged ===== */ *{box-sizing:border-box} html,body{margin:0;padding:0;width:100%;overflow-x:hidden} body{background:linear-gradient(135deg,#f1f5f9 0%,#eef2ff 100%);font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#0f172a;padding:20px} .admin-form{width:min(100%,680px);max-width:680px;margin:clamp(8px,4vw,38px) auto;background:rgba(255,255,255,.97);padding:clamp(18px,4vw,32px);border:1px solid #e2e8f0;border-radius:20px;box-shadow:0 18px 50px rgba(15,23,42,.10)} .admin-form h2{margin:0 0 22px;font-size:clamp(22px,5vw,30px);line-height:1.2;color:#0f172a;letter-spacing:-.5px} .form-group{margin-bottom:18px} .form-group label{font-size:14px;margin-bottom:8px;color:#334155} .form-group input,.form-group select,.form-group textarea{display:block;width:100%;min-height:48px;padding:12px 14px;border:1px solid #cbd5e1;border-radius:11px;background:#fff;color:#0f172a;font:inherit;outline:none;transition:border-color .2s,box-shadow .2s} .form-group textarea{min-height:96px;resize:vertical} .form-group input:focus,.form-group select:focus,.form-group textarea:focus{border-color:#64748b;box-shadow:0 0 0 4px rgba(100,116,139,.12)} .form-group input[type=file]{padding:10px;background:#f8fafc;cursor:pointer} .btn-submit{min-height:50px;padding:13px 20px;border-radius:12px;font-weight:700;box-shadow:0 8px 20px rgba(11,23,38,.16);transition:transform .15s,box-shadow .15s} .btn-submit:hover{transform:translateY(-1px);box-shadow:0 10px 24px rgba(11,23,38,.22)} .msg-box{padding:12px 14px;border:1px solid #bbf7d0;margin-bottom:20px} @media (max-width:767px){ body{padding:10px;background:#f8fafc} .admin-form{margin:0 auto;padding:18px 15px;border-radius:16px;box-shadow:0 10px 30px rgba(15,23,42,.08)} .admin-form h2{margin-bottom:18px;font-size:23px} .form-group{margin-bottom:15px} .form-group label{font-size:13px} .form-group input,.form-group select,.form-group textarea{min-height:46px;padding:11px 12px;border-radius:10px;font-size:15px} .form-group textarea{min-height:90px} .btn-submit{width:100%;min-height:48px;font-size:15px} .msg-box{font-size:14px;margin-bottom:16px} } @media (max-width:380px){ body{padding:7px} .admin-form{padding:15px 12px;border-radius:14px} .admin-form h2{font-size:21px} .form-group{margin-bottom:13px} .form-group input,.form-group select,.form-group textarea{font-size:14px} .form-group textarea{min-height:82px} .btn-submit{min-height:46px} } @media (prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;transition:none!important}} </style> </head> <body> <div class="admin-form"> <h2>Add Tour Package</h2> <?php if($msg) echo "<div class='msg-box'><b>$msg</b></div>"; ?> <form action="" method="POST" enctype="multipart/form-data"> <div class="form-group"> <label>Select Category</label> <select name="category" required> <option value="">-- Category Chunein --</option> <?php // Fetch categories dynamically from database $cat_result = mysqli_query($conn, "SELECT * FROM categories ORDER BY id DESC"); if ($cat_result && mysqli_num_rows($cat_result) > 0) { while($cat_row = mysqli_fetch_assoc($cat_result)) { $cat_name = $cat_row['name'] ?? $cat_row['category_name']; echo '<option value="'.htmlspecialchars($cat_name).'">'.htmlspecialchars($cat_name).'</option>'; } } else { echo '<option value="" disabled>No categories found. Please add a category first.</option>'; } ?> </select> </div> <div class="form-group"> <label>Package Title</label> <input type="text" name="package_title" placeholder="e.g. Premium Chardham Helicopter Tour" required> </div> <div class="form-group"> <label>Amount / Price (INR)</label> <input type="number" step="0.01" name="amount" placeholder="e.g. 195000" required> </div> <div class="form-group"> <label>Duration</label> <input type="text" name="duration" placeholder="e.g. 05 Nights / 06 Days" required> </div> <div class="form-group"> <label>Overview</label> <textarea name="overview" rows="3" required></textarea> </div> <div class="form-group"> <label>Inclusions (Comma or Bullet separated)</label> <textarea name="inclusions" rows="3"></textarea> </div> <div class="form-group"> <label>Exclusions</label> <textarea name="exclusions" rows="3"></textarea> </div> <div class="form-group"> <label>Package Image</label> <input type="file" name="package_image" accept="image/*" required> </div> <button type="submit" name="submit_package" class="btn-submit">Upload Package</button> </form> </div> </body> </html>
Save
Cancel