Skip to content
Snippets Groups Projects
Commit 4ce71198 authored by vanessrw's avatar vanessrw
Browse files

Merge branch 'FE' of gitlab.informatika.org:if3110-2023-01-18/tugas-besar-1 into FE

parents 67e7c1f2 398de686
Branches FE
Tags
No related merge requests found
...@@ -11,8 +11,8 @@ class EventModel { ...@@ -11,8 +11,8 @@ class EventModel {
// Check if a file is uploaded // Check if a file is uploaded
if ($gambar !== null && isset($gambar['name']) && isset($gambar['tmp_name'])) { if ($gambar !== null && isset($gambar['name']) && isset($gambar['tmp_name'])) {
$uploadDirectory = __DIR__ . '/../../assets/'; // $uploadDirectory = __DIR__ . '/../../assets/';
$uploadedFilePath = $uploadDirectory . $gambar['name']; $uploadedFilePath = 'assets/' . $gambar['name'];
// Move the uploaded file to the desired directory // Move the uploaded file to the desired directory
if (move_uploaded_file($gambar['tmp_name'], $uploadedFilePath)) { if (move_uploaded_file($gambar['tmp_name'], $uploadedFilePath)) {
......
<!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
<!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
...@@ -22,23 +22,23 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { ...@@ -22,23 +22,23 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$eventStock = $_POST['stock']; $eventStock = $_POST['stock'];
$eventCreatedTime = $_POST['createdTime']; $eventCreatedTime = $_POST['createdTime'];
$eventDetails = $_POST['details']; $eventDetails = $_POST['details'];
$uploadedFilePath = $_POST['gambar']; // $uploadedFilePath = $_POST['gambar'];
// Check if the values are not empty // Check if the values are not empty
if (!empty($eventStock) && !empty($eventCreatedTime) && !empty($eventDetails)) { if (!empty($eventStock) && !empty($eventCreatedTime) && !empty($eventDetails)) {
var_dump($_FILES); 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 // // Check for file upload
$uploadedFile = isset($_FILES['gambar']) ? $_FILES['gambar'] : null; // $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) { // if ($uploadedFile !== null && $uploadedFile['error'] === 0) {
// Handle file upload // // Handle file upload
$uploadedFilePath = 'assets/' . $uploadedFile['name']; // $uploadedFilePath = 'assets/' . $uploadedFile['name'];
move_uploaded_file($uploadedFile['tmp_name'], $uploadedFilePath); // move_uploaded_file($uploadedFile['tmp_name'], $uploadedFilePath);
} // }
$eventController->createEvent($eventStock, $eventCreatedTime, $eventDetails, $uploadedFilePath); $eventController->createEvent($eventStock, $eventCreatedTime, $eventDetails, $uploadedFilePath);
} else { } else {
...@@ -49,19 +49,21 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { ...@@ -49,19 +49,21 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$eventStock = $_POST['eventStock']; $eventStock = $_POST['eventStock'];
$eventCreatedTime = $_POST['eventCreatedTime']; $eventCreatedTime = $_POST['eventCreatedTime'];
$eventDetails = $_POST['eventDetails']; $eventDetails = $_POST['eventDetails'];
$uploadedFilePath = $_POST['uploadedFilePath']; var_dump($_FILES);
// $uploadedFilePath = $_POST['uploadedFilePath'];
// Check if the values are not empty // Check if the values are not empty
if (!empty($eventIdUpdate) && !empty($eventStock) && !empty($eventCreatedTime) && !empty($eventDetails)) { 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 $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 // Check for file upload
if ($uploadedFilePath !== null && $uploadedFilePath['error'] === 0) { if ($uploadedFilePath !== null && $uploadedFilePath['error'] === 0) {
// Handle file upload // Handle file upload
$uploadedFilePath = 'assets/' . $uploadedFilePath['name']; $uploadedFilePath = 'assets/' . $uploadedFile['name'];
move_uploaded_file($uploadedFilePath['tmp_name'], $uploadedFilePath); move_uploaded_file($uploadedFile['tmp_name'], $uploadedFilePath);
} }
$eventController->updateEvent($eventIdUpdate, $eventStock, $eventCreatedTime, $eventDetails, $uploadedFile); $eventController->updateEvent($eventIdUpdate, $eventStock, $eventCreatedTime, $eventDetails, $uploadedFilePath);
} else { } else {
echo "Please fill in all the fields for updating an event."; echo "Please fill in all the fields for updating an event.";
} }
...@@ -98,9 +100,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { ...@@ -98,9 +100,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
$userIdDelete = $_POST['userIdDelete']; $userIdDelete = $_POST['userIdDelete'];
$userController->deleteUser($userIdDelete); $userController->deleteUser($userIdDelete);
} elseif ($_POST['userAction'] === 'login') { } elseif ($_POST['userAction'] === 'login') {
$loginUsername = $_POST['loginUsername']; $loginEmail = $_POST['loginEmail'];
$loginPassword = $_POST['loginPassword']; $loginPassword = $_POST['loginPassword'];
echo $userController->loginByEmail($loginUsername,$loginPassword); echo $userController->loginByEmail($loginEmail,$loginPassword);
} elseif ($_POST['userAction'] === 'logout') { } elseif ($_POST['userAction'] === 'logout') {
echo $userController->logout(); echo $userController->logout();
} }
......
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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment