-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit-report.php
35 lines (29 loc) · 895 Bytes
/
submit-report.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
<?php
// Connect to the MySQL database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Handle the form submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$crime_type = $_POST["crime-type"];
$description = $_POST["description"];
$time = $_POST["time"];
$location = $_POST["location"];
// Insert the data into the MySQL database
$sql = "INSERT INTO crimes (crime_type, description, time, location)
VALUES ('$crime_type', '$description', '$time', '$location')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
// Close the MySQL connection
$conn->close();
?>