diff --git a/assets/css/style.css b/assets/css/style.css new file mode 100644 index 0000000..46c0348 --- /dev/null +++ b/assets/css/style.css @@ -0,0 +1,64 @@ +body { + font-family: 'Poppins', sans-serif; + background-color: #F4F7F6; +} + +.sidebar { + background-color: #2c3e50; /* Dark Blue-Gray */ + width: 250px; +} + +.sidebar h4 { + font-weight: 600; +} + +.sidebar .nav-link { + color: #ecf0f1; /* Light Gray */ + font-size: 1rem; + padding: 0.75rem 1rem; + border-radius: 0.5rem; + margin-bottom: 0.5rem; + transition: background-color 0.3s ease; +} + +.sidebar .nav-link.active, .sidebar .nav-link:hover { + background-color: #34495e; /* Slightly Lighter Blue-Gray */ + color: #ffffff; +} + +.sidebar .nav-link i { + width: 20px; + height: 20px; +} + +.content { + background-color: #F4F7F6; +} + +.card { + border: none; + border-radius: 0.75rem; + box-shadow: 0 4px 6px rgba(0,0,0,0.05); +} + +.btn-primary { + background-image: linear-gradient(to right, #4A90E2, #50E3C2); + border: none; + border-radius: 0.5rem; + padding: 0.75rem 1.5rem; + font-weight: 600; + transition: transform 0.2s ease; +} + +.btn-primary:hover { + transform: translateY(-2px); + box-shadow: 0 4px 8px rgba(0,0,0,0.1); +} + +.modal-content { + border-radius: 0.75rem; +} + +.form-control { + border-radius: 0.5rem; +} diff --git a/db/config.php b/db/config.php index 0e3bceb..7c4b713 100644 --- a/db/config.php +++ b/db/config.php @@ -1,17 +1,45 @@ PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); - } - return $pdo; + // Database configuration + $host = getenv('DB_HOST') ?: '127.0.0.1'; + $port = getenv('DB_PORT') ?: '3306'; + $dbname = getenv('DB_NAME') ?: 'lamp_app_db'; + $user = getenv('DB_USER') ?: 'lamp_app_user'; + $pass = getenv('DB_PASS') ?: 'lamp_app_pass'; + $charset = 'utf8mb4'; + + $dsn = "mysql:host=$host;port=$port;dbname=$dbname;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 db_init() { + $pdo = db_connect(); + $sql = " + CREATE TABLE IF NOT EXISTS students ( + id INT AUTO_INCREMENT PRIMARY KEY, + first_name VARCHAR(100) NOT NULL, + last_name VARCHAR(100) NOT NULL, + date_of_birth DATE, + email VARCHAR(100), + phone_number VARCHAR(20), + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ); + "; + $pdo->exec($sql); +} \ No newline at end of file diff --git a/index.php b/index.php index 7205f3d..8fcddd3 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,4 @@ - - - - - - New Style - - - - - - - - - - - - - - - - - - - - - -
-
-

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

-
-
- - - +// Redirect to the student management page +header("Location: students.php"); +exit(); \ No newline at end of file diff --git a/layout_footer.php b/layout_footer.php new file mode 100644 index 0000000..d7caefe --- /dev/null +++ b/layout_footer.php @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/layout_header.php b/layout_header.php new file mode 100644 index 0000000..30559d6 --- /dev/null +++ b/layout_header.php @@ -0,0 +1,34 @@ + + + + + + School Management System + + + + + + +
+ +
diff --git a/students.php b/students.php new file mode 100644 index 0000000..ae1e3a1 --- /dev/null +++ b/students.php @@ -0,0 +1,139 @@ +prepare($sql); + $stmt->execute([$first_name, $last_name, $date_of_birth, $email, $phone_number]); + $message = "Student added successfully!"; + } catch (PDOException $e) { + $error = "Error adding student: " . $e->getMessage(); + } + } else { + $error = "Please provide at least a first and last name."; + } +} + +// Fetch all students +try { + $stmt = $pdo->query("SELECT id, first_name, last_name, date_of_birth FROM students ORDER BY created_at DESC"); + $students = $stmt->fetchAll(); +} catch (PDOException $e) { + $error = "Error fetching students: " . $e->getMessage(); + $students = []; +} + +include 'layout_header.php'; +?> + +
+
+

Student Management

+ +
+ + +
+ + +
+ + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
IDNameDate of BirthActions
No students found.
+ Edit + Delete +
+
+
+
+
+ + + + +