-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddtable.php
More file actions
59 lines (46 loc) · 1.79 KB
/
addtable.php
File metadata and controls
59 lines (46 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php include "inc/header.php";
Session::init(); // Initialize session
Session::checkSession(); // Check if the user is logged in
?>
<?php include "inc/sidenav.php";?>
<?php $db = new Database(); ?>
<div class="main-content">
<h2>Dashboard / Table</h2>
<div class="container items-data-table">
<div class="table-wrapper">
<div class="formwrapper">
<form action="qrcode.php" method="post" class="add-form" id="addTableForm" onsubmit="addTable(event)">
<label for="tableName">Table Name: </label>
<input type="text" name="tableName" id="tableName" required><br>
<label for="tableCapacity">Capacity : </label>
<input type="number" min="1" name="tableCapacity" id="tableCapacity"><br>
<button type="submit" name="addTable" onclick="addTable()">Submit</button>
</form>
</div>
</div>
</div>
<Section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
function addTable(event) {
// Prevent the default form submission behavior
event.preventDefault();
// Get form data
var formData = $("#addTableForm").serialize();
// Send AJAX request
$.ajax({
type: "POST",
url: "qrcode.php",
data: formData,
success: function(response) {
// Handle the response here
alert("Table added successfully!");
// Optionally, you can update the UI or redirect the user
},
error: function(xhr, status, error) {
// Handle errors here
alert("Error adding table: " + error);
}
});
}
</script>