-
Notifications
You must be signed in to change notification settings - Fork 2
/
insert_data.php
34 lines (28 loc) · 1007 Bytes
/
insert_data.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
<?php
$servername = "localhost";
$username = "root"; // MySQL kullanıcı adı
$password = ""; // MySQL şifresi
$dbname = "park_database"; // Veritabanı adı
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get data from the GET request
if (isset($_GET['spot_name']) && isset($_GET['distance']) && isset($_GET['is_parked'])) {
$spot_name = $_GET['spot_name'];
$distance = $_GET['distance'];
$isParked = $_GET['is_parked'];
// Insert data into MySQL database
$sql = "INSERT INTO parking_data (spot_name, distance, is_parked) VALUES ('$spot_name', '$distance', '$isParked')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
} else {
echo "Data not received!";
}
$conn->close();
?>