Get value from checkbox in form

I’m building a registration form with the cookbook recipes Creating pages from frontend and Email contact form I just don’t understand how to get the value to the confirmation email and textfile. Like this it doesn’t show up anywhere if selected. Thanks a lot in advance !

Line of the form:

<input type="checkbox" id="example" name="example" value="<?= $data['example'] ?? null ?>"/>

Line of the controller:

$data = [
  'example' => get('example'),

Line of the controller:

  'data'     => [
    'example'   => esc($data['example']),

A checkbox should have a fixed value of your choice. When the box is checked, this value will be submitted, otherwise nothing will be submitted.

Then you should check if the stored or posted value is the same as the value value and mark the box as checked.

<input type="checkbox" id="example" name="example" value="something" <?= $data['example'] === 'something' ? 'checked="checked"' : null ?>/>

Thanks a lot ! It worked.