From ca0007515ff94d5b8a57def9b4de50218c5eb57f Mon Sep 17 00:00:00 2001 From: Hickmeister <35031453+Hickmeister@users.noreply.github.com> Date: Sat, 4 Jan 2025 15:21:32 +0000 Subject: [PATCH] Added printers to DB form --- public/addPrinter.php | 252 ------------------------------------ public/index.php | 80 +----------- public/printerForm.php | 211 ++++++++++++++++++++++++++++++ src/db.php | 2 +- src/header.php | 79 +++++++++++ src/login.php | 2 +- src/printers/addPrinter.php | 43 ++++++ template.php | 80 +----------- 8 files changed, 337 insertions(+), 412 deletions(-) delete mode 100644 public/addPrinter.php create mode 100644 public/printerForm.php create mode 100644 src/header.php create mode 100644 src/printers/addPrinter.php diff --git a/public/addPrinter.php b/public/addPrinter.php deleted file mode 100644 index d8e0a04..0000000 --- a/public/addPrinter.php +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - TOD Dashboard - - - - -
- - - - -
- -
- - - -
-
- - - - - - -
-
-
-
-
Add New Printer
-
-
-
- -
- -
- -
-
- - -
- -
- -
-
- - -
- -
- -
-
- - -
- -
- -
-
- - -
- -
-
- - -
-
-
-
-
-
-
-
- - - - -
-
- - - -
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/public/index.php b/public/index.php index 31cf8b9..2cd7a0f 100644 --- a/public/index.php +++ b/public/index.php @@ -38,85 +38,7 @@ -
-
- -
-
+
diff --git a/public/printerForm.php b/public/printerForm.php new file mode 100644 index 0000000..83cd36a --- /dev/null +++ b/public/printerForm.php @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TOD Dashboard + + + + +
+ + + + + + + + +
+
+ + + + + + +
+
+
+
+
Add New Printer
+
+
+ + + +
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + +
+
+
+
+
+
+
+
+ + + + + + + + + +
+
+ + + +
+ + + + +
+

Copyright © 2024. All right reserved.

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/db.php b/src/db.php index 8e1069e..45d8b3d 100644 --- a/src/db.php +++ b/src/db.php @@ -1,5 +1,5 @@ +
+ +
+ \ No newline at end of file diff --git a/src/login.php b/src/login.php index d205a52..8904eb1 100644 --- a/src/login.php +++ b/src/login.php @@ -1,6 +1,6 @@ 'error', 'message' => 'All fields are required and IP must be valid.']); + exit; + } + + try { + // Prepare SQL insert statement + $stmt = $pdo->prepare(" + INSERT INTO bambuPrinters (printerName, printerIp, mqttPassword, serialNumber) + VALUES (:printerName, :printerIp, :mqttPassword, :serialNumber) + "); + + // Execute the query with bound parameters + $stmt->execute([ + ':printerName' => $printerName, + ':printerIp' => $printerIp, + ':mqttPassword' => $accessCode, + ':serialNumber' => $serialNumber + ]); + + echo json_encode(['status' => 'success', 'message' => 'Printer successfully added!']); + } catch (PDOException $e) { + echo json_encode(['status' => 'error', 'message' => 'Error adding printer: ' . $e->getMessage()]); + } +} else { + echo json_encode(['status' => 'error', 'message' => 'Invalid request method.']); +} +?> diff --git a/template.php b/template.php index 77018a2..33993bc 100644 --- a/template.php +++ b/template.php @@ -38,85 +38,7 @@ -
- -
+