Skip to content
Snippets Groups Projects
Commit b7d68b71 authored by ZHANG David's avatar ZHANG David
Browse files

Upload New File

parent 6637621a
No related branches found
No related tags found
No related merge requests found
<?php
include 'config.php';
session_start();
if (!isset($_SESSION['user']) || $_SESSION['user']['role'] !== 'tutor') {
echo "<div class='container'><p class='error'>Access denied. Only tutors can create depots.</p><a href='login.php'>Go back</a></div>";
exit;
}
$user = $_SESSION['user'];
$tutor_id = $user['id'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$nom = $conn->real_escape_string($_POST['nom']);
$description = $conn->real_escape_string($_POST['description']);
$sql = "INSERT INTO depots (nom, description, tutor_id) VALUES ('$nom', '$description', '$tutor_id')";
if ($conn->query($sql) === TRUE) {
echo "<div class='container'><p class='success'>Depot created successfully.</p><a href='welcome.php'>Go back</a></div>";
} else {
echo "<div class='container'><p class='error'>Error: " . htmlspecialchars($conn->error, ENT_QUOTES, 'UTF-8') . "</p><a href='prof_create_depot.php'>Try again</a></div>";
}
} else {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create Depot</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php include 'sidebar.php'; ?>
<div class="main-content">
<div class="create-session-page">
<h1>Create a Depot</h1>
<form method="POST">
<label for="nom">Depot Name:</label>
<input type="text" name="nom" id="nom" required>
<label for="description">Description:</label>
<textarea name="description" id="description"></textarea>
<button type="submit">Create Depot</button>
</form>
</div>
</body>
</html>
<?php } ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment