How can you prevent HTML, PHP, and JS code from being executed when inputting text into a textarea that is stored in a database?

To prevent HTML, PHP, and JS code from being executed when inputting text into a textarea that is stored in a database, you can use the htmlspecialchars function in PHP. This function converts special characters to HTML entities, preventing any code from being executed when the text is displayed on a webpage.

// Assuming $input contains the text input from the textarea
$clean_input = htmlspecialchars($input, ENT_QUOTES, 'UTF-8');

// Store $clean_input in the database