What are potential risks of using PHP scripts to track and display bot activity on a website?

One potential risk of using PHP scripts to track and display bot activity on a website is leaving the website vulnerable to security breaches if the code is not properly sanitized and validated. To mitigate this risk, it is important to implement input validation and output encoding to prevent malicious code injection.

// Input validation to prevent malicious code injection
$bot_activity = isset($_GET['bot_activity']) ? $_GET['bot_activity'] : '';

// Output encoding to prevent XSS attacks
echo htmlspecialchars($bot_activity);