-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
45 lines (34 loc) · 1.23 KB
/
create.php
File metadata and controls
45 lines (34 loc) · 1.23 KB
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
39
40
41
42
43
44
45
<?php include 'db.php'; ?>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$title = $_POST['title'];
$content = $_POST['content'];
$conn->query("INSERT INTO posts (title, content) VALUES ('$title', '$content')");
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Create Post</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100">
<div class="bg-purple-800 text-white p-4 text-xl font-semibold">
Create Post
</div>
<div class="flex justify-center mt-10">
<form method="POST" class="bg-white p-6 rounded-xl shadow w-full max-w-3xl">
<h2 class="text-xl font-bold mb-4">Add New Post</h2>
<input type="text" name="title" placeholder="Title"
class="w-full border p-2 rounded mb-3 focus:outline-none focus:ring-2 focus:ring-indigo-400" required>
<textarea name="content" placeholder="Content"
class="w-full border p-2 rounded mb-3 focus:outline-none focus:ring-2 focus:ring-indigo-400" required></textarea>
<button type="submit"
class="w-full bg-purple-800 text-white py-2 rounded-lg hover:bg-indigo-700 transition">
Save
</button>
</form>
</div>
</body>
</html>