-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_project.php
More file actions
38 lines (35 loc) · 979 Bytes
/
add_project.php
File metadata and controls
38 lines (35 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
session_start();
require 'config/db.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = trim($_POST['name']);
if (!empty($name)) {
$stmt = $pdo->prepare("INSERT INTO projects (user_id, name) VALUES (?, ?)");
$stmt->execute([$_SESSION['user_id'], $name]);
header("Location: dashboard.php");
exit;
}
}
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Добавить проект</title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<div class="container">
<h1>Добавить проект</h1>
<form method="POST">
<input type="text" name="name" placeholder="Название проекта" required>
<button type="submit">Создать</button>
</form>
<a href="dashboard.php">Назад</a>
</div>
</body>
</html>