-
Notifications
You must be signed in to change notification settings - Fork 0
/
form2.html
157 lines (129 loc) · 4.13 KB
/
form2.html
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<!DOCTYPE html>
<html>
<div id="header"></div>
<head>
<title>Party Vendor Registration Form</title>
<style>
body {
background-image: linear-gradient(95.2deg, rgba(173, 252, 234, 1) 26.8%, rgba(192, 229, 246, 1) 64%);
}
h1 {
align-items: center;
text-align: center;
}
form {
max-width: 600px;
margin: 0 auto;
padding: 20px;
background-color: #f2f2f2;
border-radius: 5px;
}
label {
display: block;
font-size: 16px;
margin-bottom: 5px;
}
input[type="text"],
input[type="email"],
select {
width: 100%;
padding: 10px;
border-radius: 5px;
border: none;
margin-bottom: 10px;
font-size: 16px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h1>Party Vendor Registration</h1>
<form>
<label for="vendor_name">Vendor Name:</label>
<input type="text" id="vendor_name" name="vendor_name" required>
<label for="vendor_email">Email:</label>
<input type="email" id="vendor_email" name="vendor_email" required>
<label for="vendor_phone">Phone:</label>
<input type="text" id="vendor_phone" name="vendor_phone" required>
<label for='vendor_address'>Address: </label required>
<input type="text" id="vendor_address" name="vendor_address" required>
<label for="vendor_type">Vendor Type:</label>
<select id="vendor_type" name="vendor_type" required>
<option value="">--Select--</option>
<option value="caterer">Caterer</option>
<option value="decorator">Decorator</option>
<option value="entertainer">Entertainer</option>
<option value="photographer">Photographer</option>
<option value="rental">Rental</option>
<option value="other">Other</option>
</select>
<label for="vendor_image">Upload Image:(Optional)</label>
<input type="file" id="vendor_image" name="vendor_image">
<br><br>
<input type="submit" value="Submit">
</form>
<div id="footer"></div>
<script>
const form = document.querySelector('form');
form.addEventListener('submit', async (event) => {
event.preventDefault();
const databaseRef = ref(database, 'vendors');
push(databaseRef, Object.fromEntries(formData.entries()));
const formData = new FormData(form);
const response = await fetch('/api/vendor', {
method: 'POST',
body: formData
});
alert('Vendor registration successful.');
});
</script>
<script type="module">
import {initializeApp} from "https://www.gstatic.com/firebasejs/9.18.0/firebase-app.js";
import {getDatabase, ref, push} from "https://www.gstatic.com/firebasejs/9.18.0/firebase-database.js";
const firebaseConfig = {
apiKey: "AIzaSyBBoWMteoxgPM8zaYpr2yyI4I1D0g63Ezg",
authDomain: "hacktheplan-55346.firebaseapp.com",
databaseURL: "https://hacktheplan-55346-default-rtdb.firebaseio.com",
projectId: "hacktheplan-55346",
storageBucket: "hacktheplan-55346.appspot.com",
messagingSenderId: "65660152625",
appId: "1:65660152625:web:4e6cfaf5330887de399e10",
measurementId: "G-HPTW77E8NX"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
// const analytics = getAnalytics(app);
const database = getDatabase(app);
const form = document.querySelector('form');
form.addEventListener('submit', async (event) => {
event.preventDefault();
const formData = new FormData(form);
const databaseRef = ref(database, 'vendor_db');
push(databaseRef, Object.fromEntries(formData.entries()));
const response = await fetch('/api/vendor', {
method: 'POST',
body: formData
});
alert('Vendor registration successful!');
form.reset();
});
</script>
<script>
$(function () {
$("#header").load("header.html");
$("#footer").load("footer.html");
});
</script>
</body>
</html>