-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave.php
More file actions
35 lines (30 loc) · 1.05 KB
/
save.php
File metadata and controls
35 lines (30 loc) · 1.05 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
<?php
// Enable error reporting for debugging (remove this in production)
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Check if data is received
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST['page']) && isset($_POST['content'])) {
$page = $_POST['page'];
$content = $_POST['content'];
// Connect to the database
$db = new SQLite3('admin_users.db');
// Ensure the table exists
$db->exec("CREATE TABLE IF NOT EXISTS page_content (
id INTEGER PRIMARY KEY AUTOINCREMENT,
page_name TEXT UNIQUE NOT NULL,
content TEXT NOT NULL
)");
// Insert or update content
$stmt = $db->prepare("INSERT INTO page_content (page_name, content) VALUES (:page, :content)
ON CONFLICT(page_name) DO UPDATE SET content = excluded.content");
$stmt->bindValue(':page', $page, SQLITE3_TEXT);
$stmt->bindValue(':content', $content, SQLITE3_TEXT);
if ($stmt->execute()) {
echo "success";
} else {
echo "Error saving content.";
}
} else {
echo "Invalid request.";
}
?>