EMERGENCY RESPONSE WEB APP

HAZARD REPORTING

 

Hazard Reporting Form
















For information about this web guide, contact EHS@Yaskawa.com
connect_error) { die("Connection failed: " . $conn->connect_error); } // Prepare and bind $stmt = $conn->prepare("INSERT INTO hazards (name, facility, location, description, image_path) VALUES (?, ?, ?, ?, ?)"); $stmt->bind_param("sssss", $name, $facility, $location, $description, $image_path); // Set parameters and execute $name = isset($_POST['name']) ? $_POST['name'] : NULL; $facility = $_POST['facility']; $location = $_POST['location']; $description = $_POST['description']; $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["image"]["name"]); $image_path = ""; if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) { $image_path = $target_file; } else { echo "Sorry, there was an error uploading your file."; } $stmt->execute(); // Send email notification $subject = "New Hazard Report Submitted"; $body = "A new hazard report has been submitted.\n\nName: $name\nFacility: $facility\nLocation: $location\nDescription: $description\nImage: $image_path"; $headers = "From: no-reply@yaskawa.com"; if (mail($to_email, $subject, $body, $headers)) { echo "New record created successfully and email sent."; } else { echo "New record created successfully but email could not be sent."; } $stmt->close(); $conn->close(); ?>