| Server IP : 3.111.61.48 / Your IP : 216.73.216.67 Web Server : Apache System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.2.31 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/vhost/book.gyaniguru.org/admin/ |
Upload File : |
<?php
include 'includes/header.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add_photo'])) {
$title = $_POST['title'];
$price = $_POST['price'];
$original_price = $_POST['original_price'];
$width = $_POST['width'];
$height = $_POST['height'];
$frame_type = $_POST['frame_type'];
$frame_color = $_POST['frame_color'];
$orientation = $_POST['orientation'];
$print_type = $_POST['print_type'];
$weight = $_POST['weight'] ?: 0;
$stock = $_POST['stock'] ?: 1;
$badge = $_POST['badge'];
$description = $_POST['description'];
$is_featured = isset($_POST['is_featured']) ? 1 : 0;
$is_new = isset($_POST['is_new']) ? 1 : 0;
$image = "images/placeholder.png";
if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
$target_dir = "../images/";
$filename = time() . "_" . basename($_FILES["image"]["name"]);
$target_file = $target_dir . $filename;
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
$image = "images/" . $filename;
}
}
$sql = "INSERT INTO photos (title, price, original_price, width, height, frame_type, frame_color, orientation, print_type, weight, stock, image, badge, description, is_featured, is_new)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sddssssssdisssii", $title, $price, $original_price, $width, $height, $frame_type, $frame_color, $orientation, $print_type, $weight, $stock, $image, $badge, $description, $is_featured, $is_new);
if ($stmt->execute()) {
echo "<script>window.location.href='photos.php?msg=Photo added successfully';</script>";
} else {
$error = "Error: " . $conn->error;
}
}
?>
<div class="admin-card">
<div class="d-flex align-items-center gap-3 mb-4">
<a href="photos.php" class="btn-action bg-secondary bg-opacity-20 text-secondary"><i class="bi bi-chevron-left"></i></a>
<h5 class="m-0">Add New Guru Photo</h5>
</div>
<form action="" method="POST" enctype="multipart/form-data">
<div class="row g-4">
<div class="col-md-8">
<div class="row g-3">
<div class="col-md-12">
<label class="form-label">Guru Photo Title</label>
<input type="text" name="title" class="form-control" required placeholder="e.g., Yogi Maharaj in Meditation">
</div>
<div class="col-md-4">
<label class="form-label">Price (Sale)</label>
<input type="number" name="price" class="form-control" required step="0.01">
</div>
<div class="col-md-4">
<label class="form-label">Original Price</label>
<input type="number" name="original_price" class="form-control" step="0.01">
</div>
<div class="col-md-4">
<label class="form-label">Badge (Optional)</label>
<input type="text" name="badge" class="form-control" placeholder="e.g., Limited Edition">
</div>
<div class="col-md-3">
<label class="form-label">Frame Width (inch)</label>
<input type="text" name="width" class="form-control" placeholder="e.g., 8">
</div>
<div class="col-md-3">
<label class="form-label">Frame Height (inch)</label>
<input type="text" name="height" class="form-control" placeholder="e.g., 10">
</div>
<div class="col-md-3">
<label class="form-label">Frame Type</label>
<select name="frame_type" class="form-control">
<option value="">Select Frame</option>
<option value="Wood">Wood</option>
<option value="Premium Wood">Premium Wood</option>
<option value="Metal">Metal</option>
<option value="Acrylic">Acrylic</option>
<option value="Bamboo">Bamboo</option>
</select>
</div>
<div class="col-md-3">
<label class="form-label">Frame Color</label>
<select name="frame_color" class="form-control">
<option value="">Select Color</option>
<option value="Black">Black</option>
<option value="Brown">Brown</option>
<option value="Gold">Gold</option>
<option value="Silver">Silver</option>
<option value="Natural">Natural</option>
<option value="White">White</option>
</select>
</div>
<div class="col-md-3">
<label class="form-label">Orientation</label>
<select name="orientation" class="form-control">
<option value="">Select</option>
<option value="Portrait">Portrait</option>
<option value="Landscape">Landscape</option>
<option value="Square">Square</option>
<option value="Panorama">Panorama</option>
</select>
</div>
<div class="col-md-3">
<label class="form-label">Print Type</label>
<select name="print_type" class="form-control">
<option value="">Select Print</option>
<option value="Matte">Matte</option>
<option value="Glossy">Glossy</option>
<option value="Canvas">Canvas</option>
<option value="Fine Art">Fine Art</option>
<option value="Metallic">Metallic</option>
</select>
</div>
<div class="col-md-3">
<label class="form-label">Weight (g)</label>
<input type="number" name="weight" class="form-control" step="0.01" placeholder="e.g., 500">
</div>
<div class="col-md-3">
<label class="form-label">Stock</label>
<input type="number" name="stock" class="form-control" value="1" min="0">
</div>
<div class="col-12">
<label class="form-label">Description</label>
<textarea name="description" class="form-control" rows="4" placeholder="Describe the photo, location, story behind it..."></textarea>
</div>
</div>
</div>
<div class="col-md-4">
<div class="mb-4">
<label class="form-label">Guru Photo Image</label>
<div class="p-3 border border-secondary border-dashed rounded text-center" style="border-style: dashed !important;">
<i class="bi bi-cloud-arrow-up display-4 text-muted mb-2 d-block"></i>
<input type="file" name="image" class="form-control form-control-sm border-0" style="background:transparent" accept="image/*" required>
<small class="text-muted">Recommended: High resolution image</small>
</div>
</div>
<div class="mb-4 p-3 rounded" style="background: var(--cream); border: 1px solid var(--cream-dark);">
<h6 class="mb-3" style="color: var(--maroon);">Guru Photo Attributes</h6>
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" name="is_featured" id="flexSwitchCheck1">
<label class="form-check-label" for="flexSwitchCheck1">Show in Featured (Home)</label>
</div>
<div class="form-check form-switch mb-2">
<input class="form-check-input" type="checkbox" name="is_new" id="flexSwitchCheck2">
<label class="form-check-label" for="flexSwitchCheck2">Mark as New Arrival</label>
</div>
</div>
<hr style="border-color: rgba(255,255,255,0.1)">
<button type="submit" name="add_photo" class="btn btn-gold w-100 py-3">
<i class="bi bi-save me-2"></i> SAVE GURU PHOTO
</button>
</div>
</div>
</form>
</div>
<?php include 'includes/footer.php'; ?>