How can text data from a textarea field be stored in a database using PHP?

To store text data from a textarea field in a database using PHP, you need to first retrieve the data from the textarea field using the $_POST superglobal, sanitize the input to prevent SQL injection, and then insert the data into the database using SQL queries.

// Retrieve text data from textarea field
$textData = $_POST['textarea_field'];

// Sanitize the input to prevent SQL injection
$sanitizedTextData = mysqli_real_escape_string($connection, $textData);

// Insert the data into the database
$query = "INSERT INTO table_name (column_name) VALUES ('$sanitizedTextData')";
mysqli_query($connection, $query);