connect_error) { $errorMsg = date("Y-m-d H:i:s") . "\tMySQL Connection Error: " . $conn->connect_error . " for domain: " . $domain . PHP_EOL; file_put_contents($errorLogFilePath, $errorMsg, FILE_APPEND); echo "Database connection error."; } else { $dateVisited = date("Y-m-d"); $timeVisited = date("H:i:s"); // SQL injection prevention: Prepared statements $sql = "INSERT INTO log_entries (domain_name, date_visited, time_visited, visitor_ip) VALUES (?, ?, ?, ?)"; $stmt = $conn->prepare($sql); if ($stmt) { $stmt->bind_param("ssss", $domain, $dateVisited, $timeVisited, $ipAddress); if ($stmt->execute() === false) { $errorMsg = date("Y-m-d H:i:s") . "\tMySQL Error: " . $stmt->error . " for domain: " . $domain . PHP_EOL; file_put_contents($errorLogFilePath, $errorMsg, FILE_APPEND); echo "Database query error."; } else { // Log success to error log $successMsg = date("Y-m-d H:i:s") . "\tSuccessfully processed domain: " . $domain . PHP_EOL; file_put_contents($errorLogFilePath, $successMsg, FILE_APPEND); } $stmt->close(); } else { $errorMsg = date("Y-m-d H:i:s") . "\tMySQL Prepare Error: " . $conn->error . " for domain: " . $domain . PHP_EOL; file_put_contents($errorLogFilePath, $errorMsg, FILE_APPEND); echo "Database prepare error."; } $conn->close(); }}?>