diff --git a/app/Controllers/EventController.php b/app/Controllers/EventController.php index 1175a23035eeba9d1cd250eb82661b6281788b9d..2f7ff62b624aa8b56b3d59498e4dee2a6054da07 100644 --- a/app/Controllers/EventController.php +++ b/app/Controllers/EventController.php @@ -1,4 +1,4 @@ -// EventController.php + <?php // app/Controllers/EventController.php diff --git a/assets/Hero.png b/assets/Hero.png new file mode 100644 index 0000000000000000000000000000000000000000..1d4b40e03652df828e30ee66dd4d63a668a44e76 Binary files /dev/null and b/assets/Hero.png differ diff --git a/db/connect.php b/db/connect.php index 594f941f9c4e0a3ece19967fde0f18f36aecf803..2f5aa5edf9b64799905e27d463d74b6dd509904e 100644 --- a/db/connect.php +++ b/db/connect.php @@ -11,8 +11,9 @@ $sqlInit = file_get_contents(__DIR__ . '/init.sql'); $db->exec($sqlInit); - echo "Connected successfully and database initialized!<br/>"; + // echo "Connected successfully and database initialized!<br/>"; } catch (PDOException $e) { - echo "Connection failed: " . $e->getMessage(); + // echo "Connection failed: " . $e->getMessage(); } + ?> diff --git a/db/data.php b/db/data.php index 9fbefb71c2c9eefd72bfe63ef4d2f428d6e785bb..f53d8c0b0ca76a06c2870972d57fd9d4c4b10b3e 100644 --- a/db/data.php +++ b/db/data.php @@ -7,7 +7,7 @@ $sqlEvent = <<<EOF INSERT INTO events (event_stock, event_created_time, event_details, gambar) VALUES (100, '2023-09-30 10:00:00', 'Music Concert', 'assets/1.jpg'), - (50, '2023-10-05 15:30:00', 'Art Exhibition', 'assets/2.jpg'), + (50, '2023-10-05 15:30:00', 'Art Exhibition', 'assets/2.png'), (200, '2023-11-12 18:45:00', 'Sports Tournament', 'assets/3.jpg'), (75, '2023-12-03 20:00:00', 'Comedy Show', 'assets/4.jpg'), (120, '2024-01-18 14:15:00', 'Tech Conference', 'assets/5.jpg'); @@ -48,24 +48,24 @@ $db->beginTransaction(); $db->exec($sqlEvent); - echo "Successfully inserted dummy data to events table<br/>"; + // echo "Successfully inserted dummy data to events table<br/>"; $db->exec($sqlTicket); - echo "Successfully inserted dummy data to tickets table<br/>"; + // echo "Successfully inserted dummy data to tickets table<br/>"; $db->exec($sqlUser); - echo "Successfully inserted dummy data to users table<br/>"; + // echo "Successfully inserted dummy data to users table<br/>"; $db->exec($sqlPembelian); - echo "Successfully inserted dummy data to pembelian table<br/>"; + // echo "Successfully inserted dummy data to pembelian table<br/>"; $db->commit(); } catch (PDOException $e) { $db->rollBack(); - echo "Error: " . $e->getMessage(); + // echo "Error: " . $e->getMessage(); } } else { - echo "Error: Database connection not established."; + // echo "Error: Database connection not established."; } $db = null; diff --git a/db/init.php b/db/init.php index 7c8b1765be51bbba8fd2e50a73999c79a301e379..d5efdd7fbee4a7978546eb4828d86c6a208c781c 100644 --- a/db/init.php +++ b/db/init.php @@ -22,5 +22,5 @@ include 'data.php'; $db = null; -echo "Database initialization successful!"; +// echo "Database initialization successful!"; ?> diff --git a/db/reset.php b/db/reset.php index 7b19ad23a8a656e8d9b2098cf3d4f039b231eb40..1e98b7a351e2e637d0fa059e489aad7e4f08635b 100644 --- a/db/reset.php +++ b/db/reset.php @@ -7,9 +7,9 @@ $db->exec("DROP TABLE IF EXISTS events"); $db->exec("DROP TABLE IF EXISTS users"); - echo "Successfully reset the database<br/>"; + // echo "Successfully reset the database<br/>"; } catch (PDOException $e) { - echo "Error: " . $e->getMessage(); + // echo "Error: " . $e->getMessage(); } $db = null; ?> \ No newline at end of file diff --git a/index.php b/index.php index a56505e050c209d9ead2e53b21c93692521780ec..10231d4523a4bbbc0a33059f0d7af5f2a910735a 100644 --- a/index.php +++ b/index.php @@ -1,31 +1,75 @@ +<?php + session_start(); + include './db/connect.php'; + // include './db/init.php'; +?> + <!DOCTYPE html> -<html> +<html lang="en"> <head> - <title>PHP TITLE</title> + <title>TICKET KU</title> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" type="text/css" href="./styles/global.css"> + <link rel="stylesheet" type="text/css" href="./styles/navbar.css"> </head> <body> - <h1>HAI HAI HAI HAI</h1> - <p>lalalalala</p> - <?php - include './db/connect.php'; + <div class="index"> + <nav class="navbar"> + <div class="navbar-toggle" onclick="toggleMenu()">☰</div> + <ul> + <li><a href="#">Home</a></li> + <li><a href="#">Events</a></li> + <li><a href="#">Profile</a></li> + <li><a href="#">History</a></li> + </ul> + + <script defer> + function toggleMenu() { + const navbar = document.querySelector('.navbar ul'); + navbar.classList.toggle('show'); + } + </script> + </nav> - // Include other files and check for success or errors - include './db/init.php'; - // include './db/data.php'; - // include './db/reset.php'; - - // PHP code - $phpVersion = phpversion(); - echo "<p>PHP Version: $phpVersion</p>"; - ?> + <div class="hero"> + <img src="./assets/Hero.png" alt="Hero Image"> + <h1 class="hero-title">Ticket Ku</h1> + </div> + <div class="button"> + <li><a href="home.php">Edit</a></li> + </div> + <div class="events"> + <h2>All Events</h2> + <ul> + <?php + require_once './app/Controllers/EventController.php'; + $eventController = new EventController(); + // Get all events + $allEvents = $eventController->getAllEvents(); - <p>asdf</p> + // Loop through events and display details + foreach ($allEvents as $event) { + echo "<li>"; + echo "<strong>Event ID:</strong> " . $event['event_id'] . "<br>"; + echo "<strong>Stock:</strong> " . $event['event_stock'] . "<br>"; + echo "<strong>Created Time:</strong> " . $event['event_created_time'] . "<br>"; + echo "<strong>Details:</strong> " . $event['event_details'] . "<br>"; + echo "<strong>Image:</strong> <img src='" . $event['gambar'] . "' alt='Event Image' width='100'><br>"; + echo "</li>"; + } - <!-- Add the button to navigate to home.php --> - <a href="home.php"><button>Go to Home Page</button></a> + include './db/init.php'; + ?> + </ul> + </div> + <div class="footer"> + © 2023 Ticket Ku. All rights reserved. + </div> + </div> </body> -</html> \ No newline at end of file +</html> diff --git a/styles/global.css b/styles/global.css new file mode 100644 index 0000000000000000000000000000000000000000..028ae301eb8c37fdd145d9b4cb5fccee0fcb6021 --- /dev/null +++ b/styles/global.css @@ -0,0 +1,81 @@ +body, h1, h2, h3, p, img, button { + margin: 0; + padding: 0; + border: 0; +} + +body { + box-sizing: border-box; + font-family: sans-serif; +} + +.hero { + position: relative; + width: -webkit-fill-available; + height: 250px; + z-index: -1; +} + +.hero img { + width: 100%; + height: 100%; + object-fit: cover; +} + +.hero-title { + text-align: center; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + z-index: 100; + font-family: sans-serif; + font-size: xxx-large; +} + +.footer { + background-color: navy; + color: white; + text-align: center; + padding: 10px; + position: fixed; + bottom: 0; + width: 100%; + height: 43px; +} + +.index .button { + position: absolute; + right: 2%; + width: 100px; + margin-top: 10px; +} +.button { + background-color: rgb(255, 0, 47); + padding: 10px 24px; + border-radius: 50px; + cursor: pointer; + transition: 0.3s; + width: fit-content; + height: fit-content; + display: flex; + align-items: center; + justify-content: center; + /* z-index: 9999; */ + text-decoration: none; + color: white; +} + +.button a { + text-decoration: none; + color: white; +} + +.button:hover { + background-color: rgb(255, 156, 171); + color: white; +} + +.button:active { + background-color: rgb(240, 63, 96); +} diff --git a/styles/navbar.css b/styles/navbar.css new file mode 100644 index 0000000000000000000000000000000000000000..0a46a61af51c1dd8f965741d61fa77a45cf879ac --- /dev/null +++ b/styles/navbar.css @@ -0,0 +1,68 @@ +/* Navbar styles */ + +.navbar { + background-color: #333; + overflow: hidden; +} + +.navbar ul { + list-style-type: none; + margin: 0; + padding: 0; + display: flex; + justify-content: flex-end; /* Align items to the right */ +} + +.navbar li { + text-align: center; + margin-left: 15px; /* Adjust the spacing between items */ +} + +.navbar a { + display: block; + padding: 15px; + text-decoration: none; + color: white; + transition: background-color 0.3s; +} + +.navbar a:hover { + background-color: #555; +} + +/* Responsive version */ +@media screen and (max-width: 600px) { + .navbar ul { + flex-direction: column; /* Stack items vertically for small screens */ + align-items: flex-end; /* Align items to the right */ + display: none; /* Hide the menu by default */ + position: absolute; + top: 60px; /* Adjust the top position to avoid overlapping with the header */ + background-color: #333; + width: 100%; + } + + .navbar ul.show { + display: flex; /* Show the menu when active */ + } + + .navbar li { + width: 100%; + text-align: right; /* Align text to the right in the menu */ + margin: 0; + } + + .navbar a:hover { + background-color: #555; + } + + .navbar-toggle { + display: block; + position: absolute; + top: 0; + right: 0; + padding: 15px; + cursor: pointer; + color: white; + } +}