priprema_web_kol/new_photo.php
2025-12-25 00:02:39 +01:00

57 lines
2.2 KiB
PHP

<?php
require_once __DIR__ . "/functions.php";
middlewareAuthorized("admin");
$error_message = $_GET['error'] ?? '';
$is_success = isset($_GET['success']);
$categories = getCategories();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Photo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1>Add Photo</h1>
<form action="add_photo.php" method="post" enctype="multipart/form-data">
<?php if(!empty($error_message)): ?>
<div class="alert alert-danger" role="alert">
<?= $error_message ?>
</div>
<?php endif; ?>
<?php if($is_success): ?>
<div class="alert alert-success" role="alert">
File was uploaded successfully
</div>
<?php endif; ?>
<div class="mb-3">
<div class="mb-3">
<label for="file" class="form-label">Image</label>
<input class="form-control" type="file" id="file" name="file" accept="image/png">
</div>
<div class="mb-3">
<label for="category_id" class="form-label">Category</label>
<select class="form-select" name="category_id" id="category_id">
<option selected>Open to select category</option>
<?php foreach ($categories as $cat): ?>
<option value="<?= $cat['id'] ?>"><?= $cat['name'] ?></option>
<?php endforeach; ?>
</select>
</div>
<div>
<label for="description" class="form-label">Description</label>
<textarea class="form-control" id="description" name="description" rows="3"></textarea>
</div>
</div>
<button type="submit" class="btn btn-primary">Add Photo</button>
</form>
</div>
</body>
</html>