Keep getting getting an error of the variable hasn't been defined online 8 Cakephp4

Keep getting getting an error of the variable hasn’t been defined online 8 of my code the application is trying to use a variable called contact but it can’t because the variable hasn’t been defined. This is my contact us page on my website

Here’s the code how do I fix it

<?php use Cake\Core\Configure;

echo $this->Element('new-ad-top'); ?>
<div class="contact-container">
    <h2 class="section-title">Contact us</h2>
    <div class="row contact-info-row">
        <div class="col-xl-6 col-xxl-5 d-flex">
            <?php echo $this->Form->create($contact, ['class' => 'contact-form w-100 d-flex flex-column']); ?>
            <div class="info-form">
                <div class="form-group">
                    <label for="first_name">FIRST NAME</label>
                    <?php echo $this->Form->control('first_name', ['class' => 'form-control border_lg_bottom', 'placeholder' => 'Your First Name', 'div' => false, 'label' => false]); ?>
                </div>
                <div class="form-group">
                    <label for="last_name">LAST NAME</label>
                    <?php echo $this->Form->control('last_name', ['class' => 'form-control border_lg_bottom', 'placeholder' => 'Your Last Name', 'div' => false, 'label' => false]); ?>
                </div>
                <div class="form-group">
                    <label for="email">EMAIL</label>
                    <?php echo $this->Form->control('email', ['class' => 'form-control border_lg_bottom', 'placeholder' => 'Your email address', 'div' => false, 'label' => false, 'style' => 'width:233px;']); ?>
                </div>
                <div class="form-group">
                    <label for="subject">SUBJECT</label>
                    <?php echo $this->Form->control('subject', ['class' => 'form-control border_lg_bottom', 'placeholder' => 'Subject', 'div' => false, 'label' => false]); ?>
                </div>
                <div class="form-group">
                    <label for="message">YOUR MESSAGE</label>
                    <?php echo $this->Form->control('message', ['type' => 'textarea', 'class' => 'form-control border_lg_bottom', 'rows' => '10', 'label' => false]); ?>
                </div>
                <div class="form-group">
                    <label for="bp_recaptcha">Are you human</label>
                    <div class="bp_recaptcha">
                        <input type="hidden" name="recaptcha_response" id="recaptchaResponse">
                        <div class="g-recaptcha" data-sitekey="<?php echo Configure::read('Recaptcha.PublicKey'); ?>"></div>
                        <script type="text/javascript"
                                src="https://www.google.com/recaptcha/api.js"></script>
                        <script>
                            grecaptcha.ready(function () {
                                grecaptcha.execute("<?php echo Configure::read('Recaptcha.PublicKey'); ?>", {action: 'contact'}).then(function (token) {
                                    var recaptchaResponse = document.getElementById('recaptchaResponse');
                                    recaptchaResponse.value = token;
                                });
                            });
                        </script>
                    </div>
                </div>
            </div>
            <div class="btn-wrap mt-0 pt-2 pt-md-3 pt-xl-4 pb-4 pb-md-5 d-flex flex-column flex-md-row justify-content-md-end align-items-center">
                <?php echo $this->Form->submit('Send', ['class' => 'btn btn-primary']); ?>
            </div>
            <?php echo $this->Form->end(); ?>
        </div>
        <div class="col-xl-6 col-xxl-7">
            <div class="top-text">
                <p class="text-center">Create your career on this music platform<br>
                Have A Suggestion? A Problem? Feedback?<br>
                <a href="mailto:">Contact Us</a></p>
                <strong>Please see the following options before emailing.<br>If you are emailing because:</strong>
                <ul>
                  <li>You forgot your password, then please try the <?php echo $this->Html->link('reset password form', ['controller' => 'users', 'action' => 'forgotPassword']); ?>.</li>
                  <li>You want to upload mixtapes, please log into your account and then click the "Upload mixtape" tab.</p></li>
                </ul>
            </div>
            <div class="bottom-text">
                <p>Topmixtapes is the best platform in Music & Technology. Our mobile apps and website has millions of active users daily searching for the latest Singles & Mixtapes. Don't miss a chance to capture their attention.</p>
            </div>
        </div>
    </div>
    <div class="row contact-bottom-info">
        <div class="col-6 col-xl-3 pb-3 pb-md-4">
            <h2 class="section-title text-uppercase"><a href="<?= $this->Url->build(['controller' => 'pages', 'action' => 'dmca']) ?>">DMCA</a></h2>
        </div>
        <div class="col-6 col-xl-3 pb-3 pb-md-4">
            <h2 class="section-title text-uppercase"><a href="<?= $this->Url->build(['controller' => 'pages', 'action' => 'termsOfService']) ?>">TERMS OF SERVICE</a></h2>
        </div>
        <div class="col-6 col-xl-3 pb-3 pb-md-4">
            <h2 class="section-title text-uppercase"><a href="<?= $this->Url->build(['controller' => 'pages', 'action' => 'privacy']) ?>">PRIVACY POLICY</a></h2>
        </div>
        <div class="col-6 col-xl-3 pb-3 pb-md-4">
            <h2 class="section-title text-uppercase"><a href="<?= $this->Url->build(['controller' => 'pages', 'action' => 'reportAbuse']) ?>">REPORT ABUSE</a></h2>
        </div>
    </div>
</div>

If you use $this->Form->create($contact then $contact should be some sort of entity object I would guess.

Do you have a table called contacts or something like that?

In the end you have to do something like this inside your Controller

$contact = $this->Contacts->newEmptyEntity();
$this->set(compact('contact'));

to set at least an empty entity into the view.

If you don’t want your form to be related to an entity you can also use another context (or none at all for a model-less form) See Form - 4.x