-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcadastro.php
491 lines (440 loc) · 15.8 KB
/
cadastro.php
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Cadastro de Casas</title>
<style>
/* ===== RESET BÁSICO ===== */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #f4f4f9;
color: #333;
line-height: 1.6;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
padding: 20px;
}
.form-container {
background: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
max-width: 600px;
width: 100%;
}
.form-container h1 {
text-align: center;
margin-bottom: 20px;
font-size: 1.8rem;
color: #007bff;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 1rem;
}
.form-group textarea {
resize: vertical;
}
.form-group input[type="file"] {
padding: 5px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
border-color: #007bff;
outline: none;
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}
.form-footer {
text-align: center;
margin-top: 20px;
}
.form-footer button {
padding: 10px 20px;
background: #007bff;
color: #fff;
border: none;
border-radius: 5px;
font-size: 1rem;
cursor: pointer;
transition: 0.3s;
}
.form-footer button:hover {
background: #0056b3;
}
/* Estilo para a visualização de imagens */
.image-preview {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-top: 15px;
}
.image-preview img {
max-width: 100px;
border-radius: 5px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
/* Drag & Drop Múltiplo */
.drop-area {
border: 2px dashed #ccc;
border-radius: 10px;
padding: 20px;
text-align: center;
cursor: pointer;
}
.drop-area.dragover {
background-color: #f0f0f0;
border-color: #000;
}
.image-container {
position: relative;
margin: 5px;
cursor: pointer;
border: 1px solid #ddd;
border-radius: 5px;
padding: 5px;
display: inline-block;
}
.image-container:hover {
background-color: #f0f0f0;
}
.image-container span {
position: absolute;
top: 0;
left: 0;
background: #000;
color: #fff;
padding: 2px 5px;
font-size: 10px;
border-radius: 3px;
}
</style>
<script>
// Função de formatação de preço (opcional)
function formatPrice(element) {
// Exemplo simples: remove tudo que não for número e vírgula
// Ajuste conforme necessidade
}
</script>
</head>
<body>
<div class="form-container">
<h1>Cadastro de Casas</h1>
<!-- IMPORTANTE: "action" aponta para o script que processa os dados -->
<form action="processarcasas.php" method="POST" enctype="multipart/form-data">
<!-- Título da Casa -->
<div class="form-group">
<label for="title">
Título da Casa
(<span style="color:red">Obrigatório</span>)
</label>
<input
type="text"
id="title"
name="title"
placeholder="Ex: Casa no Centro com 3 Quartos"
required
>
</div>
<div class="form-group">
<label for="seo">
Título do Site (SEO)
(<span style="color:red">Obrigatório</span>)
</label>
<input
type="text"
id="seo"
name="seo"
placeholder="Ex: Apartamento com 56m²..."
required
>
</div>
<!-- Cidade -->
<div class="form-group">
<label for="cidade">
Cidade
(<span style="color:red">Obrigatório</span>)
</label>
<select id="cidade" name="cidade" required>
<option value="">Selecione a Cidade</option>
<option value="Garopaba">Garopaba</option>
<option value="Paulo Lopes">Paulo Lopes</option>
<option value="Outra">Outra</option>
</select>
</div>
<!-- Bairro -->
<div class="form-group">
<label for="bairro">
Bairro
(<span style="color:red">Obrigatório</span>)
</label>
<select id="bairro" name="bairro" required>
<option value="">Selecione o Bairro</option>
<option value="Centro">Centro</option>
<option value="Panorâmico">Panorâmico</option>
<option value="Morrinhos">Morrinhos</option>
<!-- ... e assim por diante ... -->
<option value="Cova Triste">Cova Triste</option>
</select>
</div>
<!-- Endereço -->
<div class="form-group">
<label for="rua">
Endereço
(<span style="color:red">Obrigatório</span>)
</label>
<input
type="text"
id="rua"
name="rua"
placeholder="Ex: Rua Principal, 100"
required
>
</div>
<!-- Tipo de Imóvel -->
<div class="form-group">
<label for="type">
Tipo de Imóvel
(<span style="color:red">Obrigatório</span>)
</label>
<select id="type" name="type" required>
<option value="">Selecione</option>
<option value="Casa">Casa</option>
<option value="Apartamento">Apartamento</option>
<option value="Terreno">Terreno</option>
</select>
</div>
<!-- Quartos -->
<div class="form-group">
<label for="bedrooms">
Número de Quartos
(<span style="color:red">Obrigatório</span>)
</label>
<input
type="number"
id="bedrooms"
name="bedrooms"
placeholder="Ex: 3"
required
>
</div>
<!-- Banheiros -->
<div class="form-group">
<label for="bathrooms">
Número de Banheiros
(<span style="color:red">Obrigatório</span>)
</label>
<input
type="number"
id="bathrooms"
name="bathrooms"
placeholder="Ex: 2"
required
>
</div>
<!-- Área (m2) -->
<div class="form-group">
<label for="m2">
m2
(<span style="color:red">Obrigatório</span>)
</label>
<input
type="number"
id="m2"
name="m2"
placeholder="Ex: 100"
required
>
</div>
<!-- Garagem (opcional) -->
<div class="form-group">
<label for="garage">Vagas de Garagem</label>
<input
type="number"
id="garage"
name="garage"
placeholder="Ex: 1"
>
</div>
<!-- Preço -->
<div class="form-group">
<label for="price">
Preço
(<span style="color:red">Obrigatório</span>)
</label>
<input
type="text"
id="price"
name="price"
placeholder="Ex: 500.000,00"
required
oninput="formatPrice(this)"
>
</div>
<!-- Descrição (opcional) -->
<div class="form-group">
<label for="description">Descrição</label>
(<span style="color:red">Obrigatório</span>)
<textarea
id="description"
name="description"
rows="5"
placeholder="Descreva detalhes do imóvel..."
></textarea>
</div>
<!-- Imagem de Capa (opcional) -->
<div class="form-group">
<label for="coverImage">Imagem de Capa</label>
(<span style="color:red">Obrigatório</span>)
<input
type="file"
id="coverImage"
name="coverImage"
accept="image/*"
>
<div class="image-preview" id="coverImagePreview"></div>
</div>
<!-- Script de pré-visualização da Capa -->
<script>
document.getElementById("coverImage").addEventListener("change", function() {
const preview = document.getElementById("coverImagePreview");
preview.innerHTML = ""; // Limpa anterior
const file = this.files[0];
if (file && file.type.startsWith("image/")) {
const reader = new FileReader();
reader.onload = function(e) {
const img = document.createElement("img");
img.src = e.target.result;
preview.appendChild(img);
};
reader.readAsDataURL(file);
}
});
</script>
<!-- Imagens do Imóvel (Drag & Drop, obrigatório) -->
<div class="form-group">
<label for="images">
Imagens do Imóvel
(<span style="color:red">Obrigatório</span>)
</label>
<div id="dropArea" class="drop-area">
<p>Arraste suas imagens aqui ou clique para selecionar</p>
<input
type="file"
id="images"
name="images[]"
accept="image/*"
multiple
required
hidden
>
</div>
<div class="image-preview" id="imagePreview"></div>
</div>
<script>
const dropArea = document.getElementById("dropArea");
const fileInput = document.getElementById("images");
const imagePreview = document.getElementById("imagePreview");
let filesArray = [];
dropArea.addEventListener("dragover", (event) => {
event.preventDefault();
dropArea.classList.add("dragover");
});
dropArea.addEventListener("dragleave", () => {
dropArea.classList.remove("dragover");
});
dropArea.addEventListener("drop", (event) => {
event.preventDefault();
dropArea.classList.remove("dragover");
const files = event.dataTransfer.files;
addFiles(files);
});
dropArea.addEventListener("click", () => {
fileInput.click();
});
fileInput.addEventListener("change", () => {
addFiles(fileInput.files);
});
function addFiles(files) {
for (let file of files) {
if (file.type.startsWith("image/")) {
filesArray.push(file);
}
}
renderPreview();
}
function renderPreview() {
imagePreview.innerHTML = "";
filesArray.forEach((file, index) => {
const reader = new FileReader();
reader.onload = function(e) {
const container = document.createElement("div");
container.classList.add("image-container");
container.setAttribute("data-index", index);
const imgElement = document.createElement("img");
imgElement.src = e.target.result;
imgElement.style.width = "100px";
imgElement.style.margin = "5px";
const label = document.createElement("span");
label.textContent = index === 0 ? "Imagem Principal" : "";
container.appendChild(imgElement);
container.appendChild(label);
imagePreview.appendChild(container);
// Clique para mover imagem para topo
container.addEventListener("click", () => {
moveToTop(index);
});
};
reader.readAsDataURL(file);
});
}
function moveToTop(index) {
if (index > 0) {
const selected = filesArray.splice(index, 1)[0];
filesArray.unshift(selected);
renderPreview();
}
}
</script>
<!-- Contato -->
<div class="form-group">
<label for="contact">
Contato (E-mail ou Telefone)
(<span style="color:red">Obrigatório</span>)
</label>
<input
type="text"
id="contact"
name="contact"
placeholder="Ex: [email protected]"
required
>
</div>
<!-- Botão de Enviar (importante: type="submit") -->
<div class="form-footer">
<button type="submit">Cadastrar Imóvel</button>
</div>
</form>
</div>
</body>
</html>