-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport-crime.html
82 lines (69 loc) · 2.56 KB
/
report-crime.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Report a Crime</title>
</head>
<body>
<h1>Report a Crime</h1>
<form id="crimeForm">
<label>Your Name:</label>
<input type="text" name="reporterName" required>
<label>Category:</label>
<select name="category" required>
<option value="theft">Theft</option>
<option value="assault">Assault</option>
<option value="vandalism">Vandalism</option>
<option value="kidnapping">Kidnapping</option>
<option value="banditry">Banditry</option>
<option value="terrorism">Terrorism</option>
<option value="robbery">Robbery</option>
<option value="murder">Murder</option>
<option value="human-trafficking">Human Trafficking</option>
<option value="drug-trafficking">Drug Trafficking</option>
<option value="other">Other</option>
</select>
<label>Crime Description:</label>
<textarea name="description" required></textarea>
<label>Location:</label>
<input type="text" name="location" required>
<label>Date:</label>
<input type="date" name="date" required>
<label>Time:</label>
<input type="time" name="time" required>
<label>Upload Image:</label>
<input type="file" name="image" accept="image/*">
<label>Upload Video:</label>
<input type="file" name="video" accept="video/*">
<!-- Buttons: Submit and View Reports -->
<div style="display: flex; justify-content: space-between; margin-top: 1em;">
<button type="submit">Submit Report</button>
<button type="button" id="viewReportsButton">View Reports</button>
</div>
</form>
<script>
// Handle "Submit Report" functionality
document.getElementById('crimeForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(e.target);
try {
const response = await fetch('http://localhost:5000/report-crime', {
method: 'POST',
body: formData,
});
const result = await response.json();
alert(result.message);
e.target.reset(); // Reset the form after successful submission
} catch (error) {
alert('Error submitting the report: ' + error.message);
}
});
// Redirect to admin view page
document.getElementById('viewReportsButton').addEventListener('click', () => {
window.location.href = 'admin.html';
});
</script>
</body>
</html>