Mail-Form-Data plugin with 2 forms only 1 working

Hey I am still using the previous version of Kirby. I have two forms, one of the quote page, and another on the home page. they both collect different sets of data. The one on the quote page works fine but the one on the homepage does not work. The form on the homepage submits without any errors and the page refreshes so I cannot work out where the issue is. I have labelled all files like this:

  • Controllers > home.php, quote.php.
  • Templates > email > email.php
  • Plugins > mail-form-data > mail-form-data.php

I would like to point out home.php form contains 3 input fields only all of which share the same value as quote.php.

I will share some code for context:

email.php

Hello,
Name: <?= $sender ?>,
Phone: <?= $phone ?>,
Email: <?= $email ?>,
Service: <?= $service ?>,
Pickup: <?= $pick ?>,
Dropoff: <?= $drop ?>,
Property: <?= $property ?>
Rooms: <?= $rooms ?>
Packaging: <?= $package ?>
Parking: <?= $park ?>
Items: <?= $items ?>

home.php

<?php if($success): ?>
			<div class="alert success">
				<p><?= $success ?></p>
			</div>
		<?php else: ?>
        <?php if (isset($alert['error'])): ?>
            <div class="error-message">
                <p>
                    <?= $alert['error'] ?>
                </p>
            </div>
        <?php endif ?>
        <form method="post" action="<?= $page->url() ?>">
            <div class="hero-form blue-block col-md-12 col-sm-12">
                <div class="hero-form-block">
                    <h3 class="gold-text pre-header fade-in-g">
                        Pickup Location
                    </h3>
                    <div class="honeypot">
                        <label for="website">Website <abbr title="required">*</abbr></label>
                        <input type="website" id="website" name="website" tabindex="-1">
                    </div>
                    <div class="field">
                        <input type="text" id="pick" name="pick" value="<?= $data['pick'] ?? '' ?>" placeholder="Enter the postcode of the collection" required>
                        <?= isset($alert['pick']) ? '<span class="alert error">' . html($alert['pick']) . '</span>' : '' ?>
                    </div>
                </div>
                <div class="hero-form-block">
                    <h3 class="gold-text pre-header fade-in-g">
                        Dropoff Location
                    </h3>
                    <div class="field">
                        <input type="text" id="drop" name="drop" value="<?= $data['drop'] ?? '' ?>" placeholder="Enter the postcode of the dropoff" required>
                        <?= isset($alert['drop']) ? '<span class="alert error">' . html($alert['drop']) . '</span>' : '' ?>
                    </div>
                </div>
                <div class="hero-form-block">
                    <h3 class="gold-text pre-header fade-in-g">
                        Phone Number
                    </h3>
                    <div class="field">
                        <input type="text" id="phone" name="phone" value="<?= $data['phone'] ?? '' ?>" placeholder="Enter your phone number now!" required>
                        <?= isset($alert['phone']) ? '<span class="alert error">' . html($alert['phone']) . '</span>' : '' ?>
                    </div>
                </div>
                <div class="hero-form-block">
                    <input class="button-1 fade-in same-page ease button-link" type="submit" name="submit" value="REQUEST A CALLBACK">
                </div>
            </div>
        </form>
        <?php endif ?>

quote.php

<?php if($success): ?>
			<div class="alert success">
				<p><?= $success ?></p>
			</div>
			<?php else: ?>
			<?php if (isset($alert['error'])): ?>
				<div class="error-message">
					<p>
						<?= $alert['error'] ?>
					</p>
				</div>
				<?php endif ?>
				<form method="post" action="<?= $page->url() ?>">
				<div class="col-md-12">
					<div class="honeypot">
							<label for="website">Website <abbr title="required">*</abbr></label>
							<input type="website" id="website" name="website" tabindex="-1">
						</div>
						<div class="field input-50 first-50">
							<input type="text" id="name" name="name" value="<?= $data['name'] ?? '' ?>" placeholder="Full Name" required>
							<?= isset($alert['name']) ? '<span class="alert error">' . html($alert['name']) . '</span>' : '' ?>
						</div>
						<div class="field input-50">
							<input type="text" id="phone" name="phone" value="<?= $data['phone'] ?? '' ?>" placeholder="Phone" required>
							<?= isset($alert['phone']) ? '<span class="alert error">' . html($alert['phone']) . '</span>' : '' ?>
						</div>
						<div class="field input-50 first-50">
							<input type="email" id="email" name="email" value="<?= $data['email'] ?? '' ?>" placeholder="Email" required>
							<?= isset($alert['email']) ? '<span class="alert error">' . html($alert['email']) . '</span>' : '' ?>
						</div>
						<div class="field  input-50 ">
							<select id="cars" id="service" name="service" value="<?= $data['service'] ?? '' ?>" placeholder="Select a service" required>
								<option value="Serices" selected>Choose a service</option>
								<option value="House">House</option>
								<option value="Flat">Flat</option>
								<option value="Office">Office Move</option>
								<option value="Storage">Storage Run</option>
								<option value="Courier">Courier</option>
							</select>
							<?= isset($alert['service']) ? '<span class="alert error">' . html($alert['service']) . '</span>' : '' ?>
						</div>
						<div class="field  input-50 first-50">
							<input type="text" id="pick" name="pick" value="<?= $data['pick'] ?? '' ?>" placeholder="Pick-up post code" required>
							<?= isset($alert['pick']) ? '<span class="alert error">' . html($alert['pick']) . '</span>' : '' ?>
						</div>
						<div class="field  input-50">
							<input type="text" id="drop" name="drop" value="<?= $data['drop'] ?? '' ?>" placeholder="Drop-off post code" required>
							<?= isset($alert['drop']) ? '<span class="alert error">' . html($alert['drop']) . '</span>' : '' ?>
						</div>
						<div class="field input-50 first-50">
							<input type="text" id="property" name="property" value="<?= $data['property'] ?? '' ?>" placeholder="Floor and Lift?" required>
							<?= isset($alert['property']) ? '<span class="alert error">' . html($alert['property']) . '</span>' : '' ?>
						</div>
						<div class="field  input-50 ">
							<input type="text" id="rooms" name="rooms" value="<?= $data['rooms'] ?? '' ?>" placeholder="No. of rooms" required>
							<?= isset($alert['rooms']) ? '<span class="alert error">' . html($alert['rooms']) . '</span>' : '' ?>
						</div>
						<div class="field input-50 first-50">
							<input type="text" id="package" name="package" value="<?= $data['package'] ?? '' ?>" placeholder="Do you need packaging" required>
							<?= isset($alert['package']) ? '<span class="alert error">' . html($alert['package']) . '</span>' : '' ?>
						</div>
						<div class="field  input-50">
							<input type="text" id="park" name="park" value="<?= $data['park'] ?? '' ?>" placeholder="Is there parking?" required>
							<?= isset($alert['park']) ? '<span class="alert error">' . html($alert['park']) . '</span>' : '' ?>
						</div>
						<div class="field">
							<textarea id="text" name="items" placeholder="What items are you moving? e.g Washing Machine, Double Sofa..." required><?= $data['items']?? '' ?></textarea>
							<?= isset($alert['items']) ? '<span class="alert error">' . html($alert['items']) . '</span>' : '' ?>
						</div>
						<input class="button-1 fade-in same-page ease" type="submit" name="submit" value="REQUEST A QUOTE">
					</div>
				</form>
			<?php endif ?>

mail-form-data.php

<?php

function mailFormData($data) {
    // $data (array) contains the form's sent data
    $name = $data['name'];
    $phone = $data['phone'];
    $email = $data['email'];
    $service = $data['service'];
    $pick = $data['pick'];
    $drop = $data['drop'];
    $property = $data['property'];
    $rooms = $data['rooms'];
    $package = $data['package'];
    $park = $data['park'];
    $items = $data['items'];
    
    // perform form data validation - we can use Kirby's validators,
    // available via "v":
    $errors = array();
    
    if(empty(trim($name))){ $errors[] = 'name'; }
    if(!v::email($data['email'])) { $errors[] = 'email'; }
    if(!empty($website)){ $errors[] = 'website'; }
    
    $result = array();
    $result['errors'] = $errors;
    
    // if we have validation errors, we can stop and return them:
    if(!empty($errors)){
        $result['success'] = false;
        $result['msg'] = 'Validation Failed';
        return $result;
    }
    
    // if we have no errors, we can go ahead and build an email message.
    // $to, $from and $subject can be hard-coded here, or can alternatively
    // be retrieved from values entered by the user in a page:
    $to = 'hello@mango-media.eu';
    $from = $email;
    $subject = 'Message From Your Website';
    $body = <<<BODY

From: {$name}
--------------------------------------------------------
Email: {$email}
--------------------------------------------------------
Phone: {$phone}
--------------------------------------------------------
Service: {$service}
--------------------------------------------------------
Pickup: {$pick}
--------------------------------------------------------
Dropoff: {$drop}
--------------------------------------------------------
Property: {$property}
--------------------------------------------------------
Rooms: {$rooms}
--------------------------------------------------------
Packaging: {$package}
--------------------------------------------------------
Parking: {$park}
--------------------------------------------------------
Items: {$items}
--------------------------------------------------------

BODY;
    
    // now, let's try sending the email:
    $email = email(array('to' => $to,'from' => $from,'subject' => $subject,'body' => $body));
    if($email->send()){
        // email was sent successfully
        $result['success'] = true;
        $result['msg'] = "Email sent successfully.";
    } else {
        // email delivery was not successful - report error
        $result['success'] = false;
        $result['msg'] = 'Email Delivery Failed: ' . $email->error()->message();
    }
    
    return $result;
}

The controllers or the code where the mailFormData() method is called are missing.

where would i find these so i can check?

You wrote you had those controllers?

i think this is in the mail-form-data.php file.

That file contains a function, but for this function to do anything, it must be called somewhere. And I don’t see this used anywhere in the code you posted above.

so i should add this function to each individual controller at the bottom of the page before the closing tags?

Please read the documentation about controllers.

You were saying that one form works, so I suggest you find the differences how you are handling them.

they are identical other than one has slightly less input fields… so i do not need to include mail-form-data.php to both of these files?

Ok I’ll try again.

mail-form-data.php contains a function called mailFormData(). Such a function is not automatically executed just because it sits in the plugin file. So you must be calling it somewhere. But I cannot see it being used anywhere and I don’t have a crystal ball to see where it is called if you don’t tell us.

So without this information, I’m sorry, but I can’t help you.

okay thanks, i understand i will look for this function in the js files and work out where it is being called. thank you for the help

Hi sorry I am slightly confused if i copy all the code from quote.php to the file home.php the form does not work when i am on the homepage. so I have came to the conclusion somewhere I am referencing the page quote.php, do you know where this may be please?

Here are the two controllers if this helps @texnixe

quote.php

<?php
    return function($kirby, $pages, $page) {

        $alert = null;

        if($kirby->request()->is('POST') && get('submit')) {

            // check the honeypot
            if(empty(get('website')) === false) {
                go($page->url());
                exit;
            }

            $data = [
                'name'  => get('name'),
                'phone' => get('phone'),
                'email' => get('email'),
                'service'  => get('service'),
                'pick'  => get('pick'),
                'drop'  => get('drop'),
                'property'  => get('property'),
                'rooms'  => get('rooms'),
                'package'  => get('package'),
                'park'  => get('park'),
                'items'  => get('items')
            ];

            $rules = [
                'name'  => ['required', 'minLength' => 1],
                'phone' => ['required', 'minLength' => 1],
                'email' => ['required', 'minLength' => 1],
                'service'  => ['required', 'minLength' => 1],
                'pick'  => ['required', 'minLength' => 1],
                'drop'  => ['required', 'minLength' => 1],
                'property'  => ['required', 'minLength' => 1],
                'rooms'  => ['required', 'minLength' => 1],
                'package'  => ['required', 'minLength' => 1],
                'park'  => ['required', 'minLength' => 1],
                'items'  => ['required', 'minLength' => 1]
            ];

            $messages = [
                'name'  => 'Please enter valid information',
                'phone' => 'Please enter valid information',
                'email' => 'Please enter valid information',
                'service'  => 'Please enter valid information',
                'pick'  => 'Please enter valid information',
                'drop'  => 'Please enter valid information',
                'property'  => 'Please enter valid information',
                'rooms'  => 'Please enter valid information',
                'package'  => 'Please enter valid information',
                'park'  => 'Please enter valid information',
                'items'  => 'Please enter valid information'
            ];

            // some of the data is invalid
            if($invalid = invalid($data, $rules, $messages)) {
                $alert = $invalid;

            // the data is fine, let's send the email
            } else {
                try {
                    $kirby->email([
                        'template' => 'email',
                        'from'     => 'form@mango-media.eu',
                        'replyTo'  => $data['email'],
                        'to'       => 'hello@mango-media.eu',
                        'subject'  => esc($data['name']) . ' sent you a message from your contact form',
                        'data'     => [
                            'sender' => esc($data['name']),
                            'phone' => esc($data['phone']),
                            'email' => esc($data['email']),
                            'service' => esc($data['service']),
                            'pick' => esc($data['pick']),
                            'drop'   => esc($data['drop']),
                            'property' => esc($data['name']),
                            'rooms' => esc($data['phone']),
                            'package' => esc($data['email']),
                            'park' => esc($data['park']),
                            'items' => esc($data['items']),
                        ]
                    ]);

                } catch (Exception $error) {
                    if(option('debug')):
                        $alert['error'] = 'The form could not be sent ' . $error->getMessage();
                    else:
                        $alert['error'] = 'The form could not be sent!';
                    endif;
                }

                // no exception occurred, let's send a success message
                if (empty($alert) === true) {
                    $success = 'Your message has successfully been sent, thank you!<br>We will get back to you within 48 hours Monday - Friday.';
                    $data = [];
                }
            }
        }

        return [
            'alert'   => $alert,
            'data'    => $data ?? false,
            'success' => $success ?? false
        ];
    };

home.php

<?php
    return function($kirby, $pages, $page) {

        $alert = null;

        if($kirby->request()->is('POST') && get('submit')) {

            // check the honeypot
            if(empty(get('website')) === false) {
                go($page->url());
                exit;
            }

            $data = [
                'phone' => get('phone'),
                'pick'  => get('pick'),
                'drop'  => get('drop'),
            ];

            $rules = [
                'phone'  => ['required', 'minLength' => 1],
                'pick'  => ['required', 'minLength' => 1],
                'drop'  => ['required', 'minLength' => 1],
            ];

            $messages = [
                'phone' => 'Please enter valid information',
                'pick'  => 'Please enter valid information',
                'drop'  => 'Please enter valid information',
            ];

            // some of the data is invalid
            if($invalid = invalid($data, $rules, $messages)) {
                $alert = $invalid;

            // the data is fine, let's send the email
            } else {
                try {
                    $kirby->email([
                        'template' => 'email',
                        'from'     => 'form@mango-media.eu',
                        'replyTo'  => $data['email'],
                        'to'       => 'hello@mango-media.eu',
                        'subject'  => 'sent you a message from your contact form',
                        'data'     => [
                            'phone' => esc($data['phone']),
                            'pick' => esc($data['pick']),
                            'drop'   => esc($data['drop']),
                        ]
                    ]);

                } catch (Exception $error) {
                    if(option('debug')):
                        $alert['error'] = 'The form could not be sent ' . $error->getMessage();
                    else:
                        $alert['error'] = 'The form could not be sent!';
                    endif;
                }

                // no exception occurred, let's send a success message
                if (empty($alert) === true) {
                    $success = 'Your message has successfully been sent, thank you!<br>We will get back to you within 48 hours Monday - Friday.';
                    $data = [];
                }
            }
        }

        return [
            'alert'   => $alert,
            'data'    => $data ?? false,
            'success' => $success ?? false
        ];
    };

The controller code is Kirby 3… I have no idea what you are doing. Maybe you should start with giving us your exact Kirby version.

hi @texnixe i am using version 3.5.0

@texnixe did you have any more suggestions please?

Hey I am version 3.5.0 of Kirby. I have two forms, one of the quote page, and another on the home page. they both collect different sets of data. The one on the quote page works fine but the one on the homepage does not work. The form on the homepage submits without any errors and the page refreshes so I cannot work out where the issue is. I have labelled all files like this:

Controllers > home.php, quote.php.
Templates > email > email.php
Plugins > mail-form-data > mail-form-data.php
I would like to point out home.php form contains 3 input fields only all of which share the same value as quote.php.

I will share some code for context:
/* email.php */

Hello,
Name: <?= $sender ?>,
Phone: <?= $phone ?>,
Email: <?= $email ?>,
Service: <?= $service ?>,
Pickup: <?= $pick ?>,
Dropoff: <?= $drop ?>,
Property: <?= $property ?>
Rooms: <?= $rooms ?>
Packaging: <?= $package ?>
Parking: <?= $park ?>
Items: <?= $items ?>

/*quote.php controller */

<?php
    return function($kirby, $pages, $page) {

        $alert = null;

        if($kirby->request()->is('POST') && get('submit')) {

            // check the honeypot
            if(empty(get('website')) === false) {
                go($page->url());
                exit;
            }

            $data = [
                'name'  => get('name'),
                'phone' => get('phone'),
                'email' => get('email'),
                'service'  => get('service'),
                'pick'  => get('pick'),
                'drop'  => get('drop'),
                'property'  => get('property'),
                'rooms'  => get('rooms'),
                'package'  => get('package'),
                'park'  => get('park'),
                'items'  => get('items')
            ];

            $rules = [
                'name'  => ['required', 'minLength' => 1],
                'phone' => ['required', 'minLength' => 1],
                'email' => ['required', 'minLength' => 1],
                'service'  => ['required', 'minLength' => 1],
                'pick'  => ['required', 'minLength' => 1],
                'drop'  => ['required', 'minLength' => 1],
                'property'  => ['required', 'minLength' => 1],
                'rooms'  => ['required', 'minLength' => 1],
                'package'  => ['required', 'minLength' => 1],
                'park'  => ['required', 'minLength' => 1],
                'items'  => ['required', 'minLength' => 1]
            ];

            $messages = [
                'name'  => 'Please enter valid information',
                'phone' => 'Please enter valid information',
                'email' => 'Please enter valid information',
                'service'  => 'Please enter valid information',
                'pick'  => 'Please enter valid information',
                'drop'  => 'Please enter valid information',
                'property'  => 'Please enter valid information',
                'rooms'  => 'Please enter valid information',
                'package'  => 'Please enter valid information',
                'park'  => 'Please enter valid information',
                'items'  => 'Please enter valid information'
            ];

            // some of the data is invalid
            if($invalid = invalid($data, $rules, $messages)) {
                $alert = $invalid;

            // the data is fine, let's send the email
            } else {
                try {
                    $kirby->email([
                        'template' => 'email',
                        'from'     => 'form@mango-media.eu',
                        'replyTo'  => $data['email'],
                        'to'       => 'hello@mango-media.eu',
                        'subject'  => esc($data['name']) . ' sent you a message from your contact form',
                        'data'     => [
                            'sender' => esc($data['name']),
                            'phone' => esc($data['phone']),
                            'email' => esc($data['email']),
                            'service' => esc($data['service']),
                            'pick' => esc($data['pick']),
                            'drop'   => esc($data['drop']),
                            'property' => esc($data['name']),
                            'rooms' => esc($data['phone']),
                            'package' => esc($data['email']),
                            'park' => esc($data['park']),
                            'items' => esc($data['items']),
                        ]
                    ]);

                } catch (Exception $error) {
                    if(option('debug')):
                        $alert['error'] = 'The form could not be sent ' . $error->getMessage();
                    else:
                        $alert['error'] = 'The form could not be sent!';
                    endif;
                }

                // no exception occurred, let's send a success message
                if (empty($alert) === true) {
                    $success = 'Your message has successfully been sent, thank you!<br>We will get back to you within 48 hours Monday - Friday.';
                    $data = [];
                }
            }
        }

        return [
            'alert'   => $alert,
            'data'    => $data ?? false,
            'success' => $success ?? false
        ];
    };

/*home.php controller */


<?php
    return function($kirby, $pages, $page) {

        $alert = null;

        if($kirby->request()->is('POST') && get('submit')) {

            // check the honeypot
            if(empty(get('website')) === false) {
                go($page->url());
                exit;
            }

            $data = [
                'phone' => get('phone'),
                'pick'  => get('pick'),
                'drop'  => get('drop'),
            ];

            $rules = [
                'phone'  => ['required', 'minLength' => 1],
                'pick'  => ['required', 'minLength' => 1],
                'drop'  => ['required', 'minLength' => 1],
            ];

            $messages = [
                'phone' => 'Please enter valid information',
                'pick'  => 'Please enter valid information',
                'drop'  => 'Please enter valid information',
            ];

            // some of the data is invalid
            if($invalid = invalid($data, $rules, $messages)) {
                $alert = $invalid;

            // the data is fine, let's send the email
            } else {
                try {
                    $kirby->email([
                        'template' => 'email',
                        'from'     => 'form@mango-media.eu',
                        'replyTo'  => $data['email'],
                        'to'       => 'hello@mango-media.eu',
                        'subject'  => 'sent you a message from your contact form',
                        'data'     => [
                            'phone' => esc($data['phone']),
                            'pick' => esc($data['pick']),
                            'drop'   => esc($data['drop']),
                        ]
                    ]);

                } catch (Exception $error) {
                    if(option('debug')):
                        $alert['error'] = 'The form could not be sent ' . $error->getMessage();
                    else:
                        $alert['error'] = 'The form could not be sent!';
                    endif;
                }

                // no exception occurred, let's send a success message
                if (empty($alert) === true) {
                    $success = 'Your message has successfully been sent, thank you!<br>We will get back to you within 48 hours Monday - Friday.';
                    $data = [];
                }
            }
        }

        return [
            'alert'   => $alert,
            'data'    => $data ?? false,
            'success' => $success ?? false
        ];
    };

/* home.php */
<?php if($success): ?>
			<div class="alert success">
				<p><?= $success ?></p>
			</div>
		<?php else: ?>
        <?php if (isset($alert['error'])): ?>
            <div class="error-message">
                <p>
                    <?= $alert['error'] ?>
                </p>
            </div>
        <?php endif ?>
        <form method="post" action="<?= $page->url() ?>">
            <div class="hero-form blue-block col-md-12 col-sm-12">
                <div class="hero-form-block">
                    <h3 class="gold-text pre-header fade-in-g">
                        Pickup Location
                    </h3>
                    <div class="honeypot">
                        <label for="website">Website <abbr title="required">*</abbr></label>
                        <input type="website" id="website" name="website" tabindex="-1">
                    </div>
                    <div class="field">
                        <input type="text" id="pick" name="pick" value="<?= $data['pick'] ?? '' ?>" placeholder="Enter the postcode of the collection" required>
                        <?= isset($alert['pick']) ? '<span class="alert error">' . html($alert['pick']) . '</span>' : '' ?>
                    </div>
                </div>
                <div class="hero-form-block">
                    <h3 class="gold-text pre-header fade-in-g">
                        Dropoff Location
                    </h3>
                    <div class="field">
                        <input type="text" id="drop" name="drop" value="<?= $data['drop'] ?? '' ?>" placeholder="Enter the postcode of the dropoff" required>
                        <?= isset($alert['drop']) ? '<span class="alert error">' . html($alert['drop']) . '</span>' : '' ?>
                    </div>
                </div>
                <div class="hero-form-block">
                    <h3 class="gold-text pre-header fade-in-g">
                        Phone Number
                    </h3>
                    <div class="field">
                        <input type="text" id="phone" name="phone" value="<?= $data['phone'] ?? '' ?>" placeholder="Enter your phone number now!" required>
                        <?= isset($alert['phone']) ? '<span class="alert error">' . html($alert['phone']) . '</span>' : '' ?>
                    </div>
                </div>
                <div class="hero-form-block">
                    <input class="button-1 fade-in same-page ease button-link" type="submit" name="submit" value="REQUEST A CALLBACK">
                </div>
            </div>
        </form>
        <?php endif ?>

/* home.php */

<?php if($success): ?>
			<div class="alert success">
				<p><?= $success ?></p>
			</div>
		<?php else: ?>
        <?php if (isset($alert['error'])): ?>
            <div class="error-message">
                <p>
                    <?= $alert['error'] ?>
                </p>
            </div>
        <?php endif ?>
        <form method="post" action="<?= $page->url() ?>">
            <div class="hero-form blue-block col-md-12 col-sm-12">
                <div class="hero-form-block">
                    <h3 class="gold-text pre-header fade-in-g">
                        Pickup Location
                    </h3>
                    <div class="honeypot">
                        <label for="website">Website <abbr title="required">*</abbr></label>
                        <input type="website" id="website" name="website" tabindex="-1">
                    </div>
                    <div class="field">
                        <input type="text" id="pick" name="pick" value="<?= $data['pick'] ?? '' ?>" placeholder="Enter the postcode of the collection" required>
                        <?= isset($alert['pick']) ? '<span class="alert error">' . html($alert['pick']) . '</span>' : '' ?>
                    </div>
                </div>
                <div class="hero-form-block">
                    <h3 class="gold-text pre-header fade-in-g">
                        Dropoff Location
                    </h3>
                    <div class="field">
                        <input type="text" id="drop" name="drop" value="<?= $data['drop'] ?? '' ?>" placeholder="Enter the postcode of the dropoff" required>
                        <?= isset($alert['drop']) ? '<span class="alert error">' . html($alert['drop']) . '</span>' : '' ?>
                    </div>
                </div>
                <div class="hero-form-block">
                    <h3 class="gold-text pre-header fade-in-g">
                        Phone Number
                    </h3>
                    <div class="field">
                        <input type="text" id="phone" name="phone" value="<?= $data['phone'] ?? '' ?>" placeholder="Enter your phone number now!" required>
                        <?= isset($alert['phone']) ? '<span class="alert error">' . html($alert['phone']) . '</span>' : '' ?>
                    </div>
                </div>
                <div class="hero-form-block">
                    <input class="button-1 fade-in same-page ease button-link" type="submit" name="submit" value="REQUEST A CALLBACK">
                </div>
            </div>
        </form>
        <?php endif ?>

Please don’t create duplicate topics for the same stuff, thank you!

no problem, is this an issue you have seen before? do you have any advise.
I have tried this so far:

hi is the issue down to the email.php template as it is using too many fields? i have tried removing these fields to test but this did not work. is there any more advise you can offer please?

This all would have been much easier if you had provided your controllers when I asked for them instead of posting unrelated Kirby 2 code (mail-form-data.php).

Your email template will not work because all those variables are not defined if you only pass these 3 fields to the template

  'data'     => [
                            'phone' => esc($data['phone']),
                            'pick' => esc($data['pick']),
                            'drop'   => esc($data['drop']),
                        ],