diff --git a/assets/css/custom.css b/assets/css/custom.css new file mode 100644 index 0000000..c6a006f --- /dev/null +++ b/assets/css/custom.css @@ -0,0 +1,20 @@ +/* custom.css */ +body { + background-color: #f8f9fa; +} + +.navbar { + margin-bottom: 2rem; +} + +.card-header { + background-color: #28a745; + color: white; +} + +.toast-container { + position: fixed; + top: 1rem; + right: 1rem; + z-index: 1055; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..da6e8b1 --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,9 @@ +// main.js +document.addEventListener('DOMContentLoaded', function () { + const urlParams = new URLSearchParams(window.location.search); + if (urlParams.has('success')) { + const toastEl = document.getElementById('successToast'); + const toast = new bootstrap.Toast(toastEl); + toast.show(); + } +}); diff --git a/db/config.php b/db/config.php index cc9229f..63e271a 100644 --- a/db/config.php +++ b/db/config.php @@ -8,10 +8,31 @@ define('DB_PASS', '9eb17a13-4a89-4e11-8517-0c201096e935'); function db() { static $pdo; if (!$pdo) { - $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [ - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - ]); + try { + $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + ]); + } catch (PDOException $e) { + // If the database doesn't exist, you might want to handle that here + // For now, we'll just re-throw the exception. + throw $e; + } } return $pdo; } + +function run_migrations() { + $pdo = db(); + $migrations_dir = __DIR__ . '/migrations'; + if (!is_dir($migrations_dir)) { + return; + } + $files = glob($migrations_dir . '/*.sql'); + foreach ($files as $file) { + $sql = file_get_contents($file); + if ($sql) { + $pdo->exec($sql); + } + } +} diff --git a/db/migrations/001_create_results_table.sql b/db/migrations/001_create_results_table.sql new file mode 100644 index 0000000..b354127 --- /dev/null +++ b/db/migrations/001_create_results_table.sql @@ -0,0 +1,8 @@ +-- 001_create_results_table.sql +CREATE TABLE IF NOT EXISTS results ( + id INT AUTO_INCREMENT PRIMARY KEY, + shooter_id INT NOT NULL, + result_text VARCHAR(255) NOT NULL, + comments TEXT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); diff --git a/index.php b/index.php index 7205f3d..29dd9ca 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,128 @@ prepare("INSERT INTO results (shooter_id, result_text, comments) VALUES (?, ?, ?)"); + $stmt->execute([$shooter_id, $result_text, $comments]); + + // Redirect to avoid form resubmission, with a success flag + header("Location: index.php?success=1"); + exit; + } +} + +// Fetch existing results for the shooter +$stmt = $pdo->prepare("SELECT * FROM results WHERE shooter_id = ? ORDER BY created_at DESC"); +$stmt->execute([$shooter_id]); +$results = $stmt->fetchAll(); -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); ?> - + - - - New Style - - - - - - - - - - - - - - - - - - - + + + skyderesultater + + + + + + + + + + + -
-
-

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

+ + + +
+
+
+ + +
+
+
Add New Result
+
+
+
+
+ + +
+
+ + +
+ +
+
+
+ + +
+
+
Your Past Results
+
+
+ +

You have not entered any results yet.

+ +
    + +
  • +
    +
    + +
    +

    +
  • + +
+ +
+
+ +
+
-
- + + +
+ +
+ + + - + \ No newline at end of file