From 0f66f6fedb8f6fa73e43dd88fbac74d362698503 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 12 Nov 2025 14:01:15 +0000 Subject: [PATCH] 1.1 --- db/config.php | 51 ++++++--- index.php | 293 ++++++++++++++++++++++++++------------------------ 2 files changed, 189 insertions(+), 155 deletions(-) diff --git a/db/config.php b/db/config.php index f67c34a..ac265f8 100644 --- a/db/config.php +++ b/db/config.php @@ -1,17 +1,40 @@ PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); - } - return $pdo; + $host = '127.0.0.1'; + $db = 'app'; + $user = 'app'; + $pass = 'password'; + $charset = 'utf8mb4'; + + $dsn = "mysql:host=$host;dbname=$db;charset=$charset"; + $options = [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::ATTR_EMULATE_PREPARES => false, + ]; + + try { + $pdo = new PDO($dsn, $user, $pass, $options); + return $pdo; + } catch (\PDOException $e) { + throw new \PDOException($e->getMessage(), (int)$e->getCode()); + } } + +function init_db() { + $pdo = db_connect(); + $pdo->exec("CREATE TABLE IF NOT EXISTS projects ( + id INT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + description TEXT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + );"); +} + +init_db(); +?> \ No newline at end of file diff --git a/index.php b/index.php index 7205f3d..38f3eff 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,161 @@ prepare("INSERT INTO projects (name) VALUES (?)"); + $stmt->execute([$name]); + $success = "Project '".htmlspecialchars($name)."' created successfully!"; + } else { + $error = "Project name cannot be empty."; + } + } catch (PDOException $e) { + $error = "Database error: " . $e->getMessage(); + } +} + +$projects = []; +try { + $stmt = $pdo->query("SELECT id, name, created_at FROM projects ORDER BY created_at DESC"); + $projects = $stmt->fetchAll(); +} catch (PDOException $e) { + $error = "Database error: " . $e->getMessage(); +} ?> - + - - - New Style - - - - - - - - - - - - - - - - - - - + + + Ertiga - AI App Builder + + + + + + + + + + + + + + -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

+ + + +
+
+
+
+
+

Create New Project

+
+
+ + +
+
+
+
+ +
+

My Projects

+ Projects +
+ +
+ +
+
+
+ +
No projects yet
+

Get started by creating your first project above.

+
+
+
+ + +
+
+
+
+

+ Created on: +

+ Open Project +
+
+
+ + +
+
+
+
+ +
+ + + + + +
-
- + + - + \ No newline at end of file