-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_header.php
More file actions
34 lines (27 loc) · 892 Bytes
/
save_header.php
File metadata and controls
34 lines (27 loc) · 892 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
<?php
require 'db_connection.php'; // Ensure this connects to SQLite
session_start();
$data = json_decode(file_get_contents("php://input"), true);
if (!isset($data['header'])) {
echo json_encode(["status" => "error", "message" => "Invalid input"]);
exit;
}
$header = $data['header'];
$sub = $data['sub'];
if (empty($header)) {
echo json_encode(["status" => "error", "message" => "Header cannot be empty"]);
exit;
}
// Insert data into header_table
$sql = "INSERT INTO header_table (header_text, sub_text) VALUES (:header, :sub)";
$stmt = $db->prepare($sql);
$stmt->bindValue(':header', $header, SQLITE3_TEXT);
$stmt->bindValue(':sub',$sub, SQLITE3_TEXT);
if ($stmt->execute()) {
echo json_encode(["status" => "success", "message" => "success"]);
} else {
echo json_encode(["status" => "error", "message" => "Database error"]);
}
$stmt->close();
$db->close();
?>