How can PHP developers ensure that a database cell remains empty if a specific value is entered in an input field?

To ensure that a database cell remains empty if a specific value is entered in an input field, PHP developers can check the input value before updating the database. If the input value matches the specific value, the database cell should be set to NULL instead of the input value.

// Check if the input value is the specific value
if ($_POST['input_field'] == 'specific_value') {
    $value = NULL; // Set the database cell to NULL
} else {
    $value = $_POST['input_field']; // Use the input value
}

// Update the database with the value
$query = "UPDATE table_name SET column_name = :value WHERE id = :id";
$stmt = $pdo->prepare($query);
$stmt->execute(['value' => $value, 'id' => $id]);