PHP Form Won't Send - Missing PHP for Submit Button

I have inherited a site with a PHP form that has stopped working. The level of coding is beyond my skills, however I think there may be a simple solution, as the form previously worked fine. Is there a piece of PHP that needs adding to make the submit button at the bottom post the gathered information? Here is the top and bottom of the form with the PHP code. I removed a large part of the form body (it is too big to paste it all) and some HTML text (replaced with ‘text removed’). I believe the important code is still present. Any help or advice will be so much appreciated:

<?php
/**
 * Template Name: Package
 *
 * @package WordPress
 * @subpackage Twenty_Seventeen
 * @since 1.0
 * @version 1.0
 */

get_header(); ?>

<div class="wrap">
    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">
                        
            <article id="package" class="page">
                <div class="entry-content">                 
                    <div class="home-wrap side-padding max-width-1000">
                        <h1 class="page-title-handwriting padding-top-0pt4em"><?php the_title(); ?></h1>                                                
                    </div>  
                    
                    <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') : ?>
                    
                    <?php // Grab submitted fields
                    $flagStyle = $_POST['flag-style'];
                    $palette = $_POST['palette'];
                    $noOfFlags = $_POST['no-of-flags'];
                    $addBunting = $_POST['add-bunting'];
                    $buntingLocation = $_POST['bunting-location'];
                    $buntingLength = $_POST['length'];
                    $deliveryOption = $_POST['delivery-option'];
                    $buntingRefolding = $_POST['bunting-refolding'];                    
                    $firstName = $_POST['your-first-name'];
                    $surname = $_POST['your-surname'];
                    $emailAddress = $_POST['your-email'];
                    $phoneNumber = $_POST['your-phone'];
                    $eventDate = $_POST['event-date'];
                    $eventEndDate = $_POST['event-end-date'];
                    $eventPostcode = $_POST['event-postcode'];
                    $deliveryAddress = $_POST['delivery-address'];
                    $deliveryAddressType = $_POST['delivery-address-type'];
                    $deliveryContact = $_POST['event-contact'];
                    $additionalComments = $_POST['additional-comments'];
                    
                    // Send the details by email
                    $headers = "From: Event Flag Hire<hello@eventflaghire.co.uk>\r\n" . 'Reply-To: ' . $emailAddress;
                    $to = "lanx@lanxworld.com";
                    $to = "studio@eventflaghire.co.uk";
                    $subject = "PACKAGE QUOTE ENQUIRY FORM";
$message = "
CUSTOMER DETAILS\r\n
Name: {$firstName} {$surname}\r\nEmail: {$emailAddress}\r\nTelephone: {$phoneNumber}\r\n";

$message .= "
FLAG SPECIFICATION\r\n
Flag Style: {$flagStyle}\r\nPalette: {$palette}\r\nNumber of flags: {$noOfFlags}\r\n";

$message .= "
ADD ADDITIONAL BUNTING?\r\n
Would you like to add additional bunting?: {$addBunting}\r\n";
$message .= "Bunting location: {$buntingLocation}\r\n";

if($addBunting == 'Yes'){
$message .= "Bunting length: {$buntingLength}m\r\n";
}

$message .= "
Bunting refolding required?: {$buntingRefolding}\r\n";

$message .= "
DELIVERY\r\n
Delivery option: {$deliveryOption}\r";
if($deliveryOption == 'Deliver'){
$message .= "
Address Type: {$deliveryAddressType}";
}

$message .= "
\r\nEVENT DETAILS\r\n
Event date: {$eventDate}\r\nEnd date (if event is more than one day): {$eventEndDate}\r\n";

if($deliveryOption == 'Deliver'){
$message .= "\r\nDelivery address: 
{$deliveryAddress}\r\n{$eventPostcode}\r\nDelivery contact: {$deliveryContact}\r\n";    
}

$message .= "
ADDITIONAL COMMENTS\r\n
{$additionalComments}\r\n";

                    mail($to, $subject, $message, $headers);                                                    
                    ?>
                    
                    <div class="home-wrap side-padding max-width-1000" style="text-align:center;">
                        <h3 class="center padding-top-1em padding-bottom-1em no-text-transform mobile-side-padding text-left"><strong>Thanks for sending your enquiry through for your flag package.</strong></h3>
                        <p>We will send text removed</p>
                        <p>For more decor please <a href="text removed">text removed</a>.</p>
                    </div>
                    
                    <?php else: ?>                                  
                    
                    <form id="package-enquiry-form" method="post" action="<?php the_permalink(); ?>">
                    
                    <div id="package-loader" class="clearboth flag-strip">
                        <div class="loader">Loading, please wait&helip;</div>
                    </div>
                    
                    <div id="package-step01" class="clearBoth flag-strip">
                        <fieldset class="package-section-title side-padding max-width-1000">
                            <legend><strong>Step 1:</strong> Choose your flag style</legend>
                            
 
                    
                    <div id="package-step07" class="clearBoth flag-strip">
                        <fieldset class="package-section-title side-padding max-width-1000">
                            <legend><strong>Step 7:</strong> Enter your event details</legend>
                            
                            <div class="your-details">
                                <div class="question-with-note">
                                    <label for="event-date">Date of event*</label>                                  
                                    <input type="text" class="datepicker" name="event-date" id="event-date" required>
                                    <a class="info-link" href="#">Information</a>
                                    <div class="question-note">
                                        <p>Weekly rental period   . . .</p>
                                    </div>          
                                </div>
                                
                                <label for="event-end-date">End date (if event is more than one day)</label>
                                <input type="text" class="datepicker" name="event-end-date" id="event-end-date">                                                                
                                
                                <label for="event-postcode">Delivery postcode*</label>
                                <input type="text" name="event-postcode" id="event-postcode" required>
                                
                                <div class="delivery-specific-field">
                                    <div class="question-with-note">
                                        <label for="delivery-address">Delivery address*</label>                                     
                                        <textarea name="delivery-address" id="delivery-address"></textarea>
                                        <a class="info-link" href="#">Information</a>
                                        <div class="question-note">
                                            <p>This should be an address  . . .</p>
                                        </div>
                                    </div>

                                    <label for="event-contact">Contact name text removed</label>
                                    <input type="text" name="event-contact" id="event-contact">
                                </div>
                                
                                <label for="additional-comments">Any additional comments/requirements?</label>
                                <p><small>For example text removed</small></p>
                                <textarea name="additional-comments" id="additional-comments"></textarea>
                                
                                <p>By sending your enquiry you agree to our <a href="/terms-conditions/" target="_blank" rel="noopener">terms and conditions</a>.</p>
                                
                                <input type="submit" value="Send enquiry">                                                          
                            </div>
                        </fieldset>
                    </div>
                                                            
                    </form>
                    <?php endif; ?>
                        
                    </div>
                            
                    
                </div><!-- .entry-content -->
            </article><!-- #post-## -->

        </main><!-- #main -->
    </div><!-- #primary -->
</div><!-- .wrap -->

<?php get_footer();
``<?php
/**
 * Template Name: Package
 *
 * @package WordPress
 * @subpackage Twenty_Seventeen
 * @since 1.0
 * @version 1.0
 */

get_header(); ?>

<div class="wrap">
    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">
                        
            <article id="package" class="page">
                <div class="entry-content">                 
                    <div class="home-wrap side-padding max-width-1000">
                        <h1 class="page-title-handwriting padding-top-0pt4em"><?php the_title(); ?></h1>                                                
                    </div>  
                    
                    <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') : ?>
                    
                    <?php // Grab submitted fields
                    $flagStyle = $_POST['flag-style'];
                    $palette = $_POST['palette'];
                    $noOfFlags = $_POST['no-of-flags'];
                    $addBunting = $_POST['add-bunting'];
                    $buntingLocation = $_POST['bunting-location'];
                    $buntingLength = $_POST['length'];
                    $deliveryOption = $_POST['delivery-option'];
                    $buntingRefolding = $_POST['bunting-refolding'];                    
                    $firstName = $_POST['your-first-name'];
                    $surname = $_POST['your-surname'];
                    $emailAddress = $_POST['your-email'];
                    $phoneNumber = $_POST['your-phone'];
                    $eventDate = $_POST['event-date'];
                    $eventEndDate = $_POST['event-end-date'];
                    $eventPostcode = $_POST['event-postcode'];
                    $deliveryAddress = $_POST['delivery-address'];
                    $deliveryAddressType = $_POST['delivery-address-type'];
                    $deliveryContact = $_POST['event-contact'];
                    $additionalComments = $_POST['additional-comments'];
                    
                    // Send the details by email
                    $headers = "From: Event Flag Hire<hello@eventflaghire.co.uk>\r\n" . 'Reply-To: ' . $emailAddress;
                    $to = "lanx@lanxworld.com";
                    $to = "studio@eventflaghire.co.uk";
                    $subject = "PACKAGE QUOTE ENQUIRY FORM";
$message = "
CUSTOMER DETAILS\r\n
Name: {$firstName} {$surname}\r\nEmail: {$emailAddress}\r\nTelephone: {$phoneNumber}\r\n";

$message .= "
FLAG SPECIFICATION\r\n
Flag Style: {$flagStyle}\r\nPalette: {$palette}\r\nNumber of flags: {$noOfFlags}\r\n";

$message .= "
ADD ADDITIONAL BUNTING?\r\n
Would you like to add additional bunting?: {$addBunting}\r\n";
$message .= "Bunting location: {$buntingLocation}\r\n";

if($addBunting == 'Yes'){
$message .= "Bunting length: {$buntingLength}m\r\n";
}

$message .= "
Bunting refolding required?: {$buntingRefolding}\r\n";

$message .= "
DELIVERY\r\n
Delivery option: {$deliveryOption}\r";
if($deliveryOption == 'Deliver'){
$message .= "
Address Type: {$deliveryAddressType}";
}

$message .= "
\r\nEVENT DETAILS\r\n
Event date: {$eventDate}\r\nEnd date (if event is more than one day): {$eventEndDate}\r\n";

if($deliveryOption == 'Deliver'){
$message .= "\r\nDelivery address: 
{$deliveryAddress}\r\n{$eventPostcode}\r\nDelivery contact: {$deliveryContact}\r\n";    
}

$message .= "
ADDITIONAL COMMENTS\r\n
{$additionalComments}\r\n";

                    mail($to, $subject, $message, $headers);                                                    
                    ?>
                    
                    <div class="home-wrap side-padding max-width-1000" style="text-align:center;">
                        <h3 class="center padding-top-1em padding-bottom-1em no-text-transform mobile-side-padding text-left"><strong>Thanks for sending your enquiry through for your flag package.</strong></h3>
                        <p>We will send text removed</p>
                        <p>For more decor please <a href="text removed">text removed</a>.</p>
                    </div>
                    
                    <?php else: ?>                                  
                    
                    <form id="package-enquiry-form" method="post" action="<?php the_permalink(); ?>">
                    
                    <div id="package-loader" class="clearboth flag-strip">
                        <div class="loader">Loading, please wait&helip;</div>
                    </div>
                    
                    <div id="package-step01" class="clearBoth flag-strip">
                        <fieldset class="package-section-title side-padding max-width-1000">
                            <legend><strong>Step 1:</strong> Choose your flag style</legend>
                            
 
                                
                                <label for="event-end-date">End date (if event is more than one day)</label>
                                <input type="text" class="datepicker" name="event-end-date" id="event-end-date">                                                                
                                
                                <label for="event-postcode">Delivery postcode*</label>
                                <input type="text" name="event-postcode" id="event-postcode" required>
                                
                                <div class="delivery-specific-field">
                                    <div class="question-with-note">
                                        <label for="delivery-address">Delivery address*</label>                                     
                                        <textarea name="delivery-address" id="delivery-address"></textarea>
                                        <a class="info-link" href="#">Information</a>
                                        <div class="question-note">
                                            <p>This should be an address  . . .</p>
                                        </div>
                                    </div>

                                    <label for="event-contact">Contact name text removed</label>
                                    <input type="text" name="event-contact" id="event-contact">
                                </div>
                                
                                <label for="additional-comments">Any additional comments/requirements?</label>
                                <p><small>For example text removed</small></p>
                                <textarea name="additional-comments" id="additional-comments"></textarea>
                                
                                <p>By sending your enquiry you agree to our <a href="/terms-conditions/" target="_blank" rel="noopener">terms and conditions</a>.</p>
                                
                                <input type="submit" value="Send enquiry">                                                          
                            </div>
                        </fieldset>
                    </div>
                                                            
                    </form>
                    <?php endif; ?>
                        
                    </div>
                            
                    
                </div><!-- .entry-content -->
            </article><!-- #post-## -->

        </main><!-- #main -->
    </div><!-- #primary -->
</div><!-- .wrap -->

<?php get_footer();

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like

Thank you! I will do that next time.

This is now solved. I changed the mail() function to wp_mail() and everything is working again.