diff --git a/app/Models/Event.php b/app/Models/Event.php index 405245da8f1c51bcce701a57b3c62f7e7ef38d53..58c634f635b183f70cddf4dcb86589d65a8822ad 100644 --- a/app/Models/Event.php +++ b/app/Models/Event.php @@ -11,8 +11,8 @@ class EventModel { // Check if a file is uploaded if ($gambar !== null && isset($gambar['name']) && isset($gambar['tmp_name'])) { - $uploadDirectory = __DIR__ . '/../../assets/'; - $uploadedFilePath = $uploadDirectory . $gambar['name']; + // $uploadDirectory = __DIR__ . '/../../assets/'; + $uploadedFilePath = 'assets/' . $gambar['name']; // Move the uploaded file to the desired directory if (move_uploaded_file($gambar['tmp_name'], $uploadedFilePath)) { diff --git a/app/View/login.php b/app/View/login.php new file mode 100644 index 0000000000000000000000000000000000000000..501ebe110f7c42a0438431b06b935a46e6921a78 --- /dev/null +++ b/app/View/login.php @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html lang="en"> + + <head> + <title>Login • 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/auth.css"> + </head> + + <body> + <div class="login-container"> + <h1>Login</h1> + <form id="loginForm" method="post" action="../../home.php"> + <!-- Aslinya email atau username bisa(?) --> + <label for="email">Email</label> + <input type="email" id="email" name="loginEmail" required> + + <label for="password">Password</label> + <input type="password" id="password" name="loginPassword" required> + + <button type="submit" name="userAction" value="login">Login</button> + </form> + <p>Don't have an account? <a href="register.php">Register</a></p> + </div> + </body> +</html> \ No newline at end of file diff --git a/app/View/register.php b/app/View/register.php new file mode 100644 index 0000000000000000000000000000000000000000..ed6173b0f0440ad83dcf9799e89cff60c219bcd5 --- /dev/null +++ b/app/View/register.php @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html lang="en"> + + <head> + <title>Register • 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/auth.css"> + </head> + + <body> + <div class="register-container"> + <h1>Register</h1> + <form id="registerForm" method="post" action="../../home.php"> + <label for="userName">Name</label> + <input type="text" id="userName" name="userName" required> + + <label for="userUsername">Username</label> + <input type="text" id="userUsername" name="userUsername" required> + + <label for="userEmail">Email</label> + <input type="email" id="userEmail" name="userEmail" required> + + <label for="userPassword">Password</label> + <input type="password" id="userPassword" name="userPassword" required> + + <label for="isAdmin" class="checkbox-label"> + Admin <input type="checkbox" id="isAdmin" name="isAdmin" value="1"> + </label> + + <button type="submit" name="userAction" value="createUser">Register</button> + </form> + <p>Already have an account? <a href="login.php">Login</a></p> + </div> + </body> +</html> \ No newline at end of file diff --git a/home.php b/home.php index f436b46f0030d241cd23849b9171e0df3f8901e1..f6a7bdd2312388a6ace6ea7b4af552ace2b16aa5 100644 --- a/home.php +++ b/home.php @@ -22,23 +22,23 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $eventStock = $_POST['stock']; $eventCreatedTime = $_POST['createdTime']; $eventDetails = $_POST['details']; - $uploadedFilePath = $_POST['gambar']; + // $uploadedFilePath = $_POST['gambar']; // Check if the values are not empty if (!empty($eventStock) && !empty($eventCreatedTime) && !empty($eventDetails)) { var_dump($_FILES); - $uploadedFilePath = isset($_FILES['gambar']) ? $_FILES['gambar'] : null; // Check if 'gambar' is set in the files array + $uploadedFilePath = isset($_FILES['gambar']) && $_FILES['gambar']['error'] === 0 ? $_FILES['gambar'] : null; // Check if 'gambar' is set in the files array - // Check for file upload - $uploadedFile = isset($_FILES['gambar']) ? $_FILES['gambar'] : null; + // // Check for file upload + // $uploadedFile = isset($_FILES['gambar']) ? $_FILES['gambar'] : null; - var_dump($uploadedFile); // Output for debugging purposes + // var_dump($uploadedFile); // Output for debugging purposes - if ($uploadedFile !== null && $uploadedFile['error'] === 0) { - // Handle file upload - $uploadedFilePath = 'assets/' . $uploadedFile['name']; - move_uploaded_file($uploadedFile['tmp_name'], $uploadedFilePath); - } + // if ($uploadedFile !== null && $uploadedFile['error'] === 0) { + // // Handle file upload + // $uploadedFilePath = 'assets/' . $uploadedFile['name']; + // move_uploaded_file($uploadedFile['tmp_name'], $uploadedFilePath); + // } $eventController->createEvent($eventStock, $eventCreatedTime, $eventDetails, $uploadedFilePath); } else { @@ -49,19 +49,21 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $eventStock = $_POST['eventStock']; $eventCreatedTime = $_POST['eventCreatedTime']; $eventDetails = $_POST['eventDetails']; - $uploadedFilePath = $_POST['uploadedFilePath']; + var_dump($_FILES); + // $uploadedFilePath = $_POST['uploadedFilePath']; // Check if the values are not empty if (!empty($eventIdUpdate) && !empty($eventStock) && !empty($eventCreatedTime) && !empty($eventDetails)) { $uploadedFilePath = isset($_FILES['gambar']) ? $_FILES['gambar'] : null; // Check if 'gambar' is set in the files array - + + $uploadedFile = isset($_FILES['gambar']) ? $_FILES['gambar'] : null; // Check for file upload if ($uploadedFilePath !== null && $uploadedFilePath['error'] === 0) { // Handle file upload - $uploadedFilePath = 'assets/' . $uploadedFilePath['name']; - move_uploaded_file($uploadedFilePath['tmp_name'], $uploadedFilePath); + $uploadedFilePath = 'assets/' . $uploadedFile['name']; + move_uploaded_file($uploadedFile['tmp_name'], $uploadedFilePath); } - $eventController->updateEvent($eventIdUpdate, $eventStock, $eventCreatedTime, $eventDetails, $uploadedFile); + $eventController->updateEvent($eventIdUpdate, $eventStock, $eventCreatedTime, $eventDetails, $uploadedFilePath); } else { echo "Please fill in all the fields for updating an event."; } @@ -98,9 +100,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { $userIdDelete = $_POST['userIdDelete']; $userController->deleteUser($userIdDelete); } elseif ($_POST['userAction'] === 'login') { - $loginUsername = $_POST['loginUsername']; + $loginEmail = $_POST['loginEmail']; $loginPassword = $_POST['loginPassword']; - echo $userController->loginByEmail($loginUsername,$loginPassword); + echo $userController->loginByEmail($loginEmail,$loginPassword); } elseif ($_POST['userAction'] === 'logout') { echo $userController->logout(); } diff --git a/styles/auth.css b/styles/auth.css new file mode 100644 index 0000000000000000000000000000000000000000..23bb7d675891fd0f74fc7010cbe9526103293bfc --- /dev/null +++ b/styles/auth.css @@ -0,0 +1,73 @@ +body { + font-family: Arial, sans-serif; + background-color: #f8f8f8; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; +} + +.login-container, .register-container { + background-color: white; + padding: 20px; + border-radius: 5px; + width: 300px; + text-align: center; +} + +.register-container { + background-color: white; + padding: 20px; + border-radius: 5px; + width: 300px; + text-align: center; +} + +label { + display: block; + margin: 10px 0 5px 0; + text-align: left; +} + +input { + width: calc(100% - 20px); + padding: 10px; + margin-bottom: 10px; + border-radius: 5px; + border: 1px solid #ccc; +} + +button { + background-color: #97A5CE; /* Green */ + border: none; + color: white; + padding: 15px 32px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 16px; + margin: 4px 2px; + transition-duration: 0.4s; + cursor: pointer; +} + +button:hover { + background-color: white; + color: black; + border: 1px solid #97A5CE; +} + +a { + color: #97A5CE; +} + +a:hover { + text-decoration: underline; +} + +.checkbox-label { + display: flex; + margin: 15px 0; + text-align: left; +} \ No newline at end of file