Skip to content
Snippets Groups Projects
Commit 450361e1 authored by Muhammad Rifko Favian's avatar Muhammad Rifko Favian
Browse files

feat: update event page (temp), ajax functionality

parent 6c1e5782
No related merge requests found
<!DOCTYPE html>
<html lang="en">
<head>
<title>Create an Event</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="../../../styles/navbar.css">
<link rel="stylesheet" type="text/css" href="../../../styles/footer.css">
</head>
<body>
<?php include '../template/navbar.php';?>
<h1>Update Event</h1>
<form method="post" action="../../router.php" enctype="multipart/form-data">
<input type="hidden" name="eventId" value="<?php echo $_GET['id']; ?>">
<input type="text" name="eventName" placeholder="Name" required>
<input type="text" name="eventPrice" placeholder="Price" required>
<input type="datetime-local" name="eventDate" required>
<input type="text" name="eventLocation" placeholder="Location" required>
<!-- Drag-and-drop area for image upload -->
<div id="drop-area-create">
<p>Drag and drop an image file here or click to select one.</p>
<input type="file" id="file-input-create" name="gambar" accept="image/*">
</div>
<!-- <input type="text" name="vid" placeholder="Video URL"> -->
<div id="drop-area-create">
<p>Drag and drop an video file here or click to select one.</p>
<input type="file" id="file-input-create" name="vid" accept="video/*">
</div>
<button type="submit" name="eventAction" value="updateEvent">Update</button>
</form>
<?php include '../template/footer.php';?>
<script>
// get event id from get request
const urlParams = new URLSearchParams(window.location.search);
const eventId = urlParams.get('id');
document.addEventListener("DOMContentLoaded", function(){
// Fetch user data on page load
fetch('../../router.php?eventAction=getEvent&eventId=' + eventId)
.then(response => response.json())
.then(data => {
console.log(data);
// Populate the form fields with the data
document.querySelector('input[name="eventName"]').value = data.event_name;
document.querySelector('input[name="eventPrice"]').value = data.event_price;
document.querySelector('input[name="eventDate"]').value = data.event_date;
document.querySelector('input[name="eventLocation"]').value = data.event_location;
})
.catch(error => console.error(error));
});
</script>
</body>
</html>
\ 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