Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "id1602076_smarttrafficlight";
- $password = "iloveJESUS<3";
- $dbname = "id1602076_smarttrafficlight";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- echo "Connected successfully\n";
- if(getenv('REQUEST_METHOD') == 'POST') {
- $input = file_get_contents("php://input");
- $input = json_decode($input, true); // decode JSON to associative array
- print_r($input);
- $duration = $input["duration"];
- $sql = "INSERT INTO traffic_data (region, tl_condition, RED_duration, GREEN_duration) VALUES ('Dago 01', 'Active', '7', '$duration')";
- if ($conn->query($sql) === TRUE) {
- echo "New record inserted successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement