Jump to content

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


Go to solution Solved by gizmola,

Recommended Posts

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();

 

the double posted code is the same form, but with a different amount removed for posting by the op. the 13 lines starting with the id="package-step07" div has been additionally removed from the second posting.

code doesn't just stop working, so you will need to investigate what is actually occurring. is the form processing code actually getting executed? are there any php errors getting displayed/logged? you will likely need to check with your web server administration as to what is happening with these emails on the mail server.

 a bunch of recommendations -

  1. email can be unreliable. you should store the submitted form data in an database table or a log file so that you have record of the form submissions.
  2. the form processing code should NOT copy variables to other variables for nothing. this is just a waste of typing. keep the form data as a set in a php array variable, then operate on elements in this array variable throughout the rest of the code.
  3. as a more advanced programming task, if you have more than 2-3 form fields, you should use a data-driven design and dynamically validate and process the form data.
  4. you need to trim all the input data before using it, mainly to detect if all white-space characters were entered. after you do item #2 on this list, you can accomplish this will one single line of code.
  5. you need to validate all the trimmed input data before using it, storing user/validation errors in an array using the field name as the main array index. 'required' fields must not be equal to an empty string and fields that must have a specific format, such as an email address, must be validated to insure they have that format.
  6. after the end of the validation logic, if there are no validation errors (the array holding the user/validation errors will be empty), use the form data.
  7. you need to apply htmlentities() to all the submitted form data, after validating it and before using it in an email or in form field values, to help prevent cross site scripting.
  8. you must test the return value from the mail() call. if it is a false value, setup a general failure message for the user and log all the relevant data from the request, such as - date/time, ip address, form data, ...
  9. the form fields should be 'sticky' and repopulate the field values upon any user/validation errors, so that the user doesn't need to keep reentering data over and over.

note: if there are user/validation errors, you would redisplay the form, therefore it should not be inside the else conditional for a post method form having been submitted.

if this stopped working, the most likely cause is that it is being used to send spam. by not validating the submitted email address (see item #5 on the above list) and putting the submitted value into the mail header, a spammer can send anything to anyone he wants through your mail server.

Thanks for the answers. I see no errors. 

22 hours ago, dodgeitorelse3 said:

Do you get any errors? What isn't working? Where is the_permalink() defined at? When submitted what do you see?

The template completely overrides the content of a WordPress page. Before this override, the WordPress page had a shortcode for a Contact Form 7 form. The form looked messy. A previous developer made this template, which should within itself, collect data from the defined fields (this part I believe works), and then submit this data to to an email address. I can't see any code which would complete the latter. When the submit button is pressed, a success message shows, but nothing is sent. What I'm wondering, is how can I make the content gathered by the rest of the code (some of which is missing but I believe it works) send an email? Is there anything obvious that is missing? 

1 hour ago, mac_gyver said:

the double posted code is the same form, but with a different amount removed for posting by the op. the 13 lines starting with the id="package-step07" div has been additionally removed from the second posting.

code doesn't just stop working, so you will need to investigate what is actually occurring. is the form processing code actually getting executed? are there any php errors getting displayed/logged? you will likely need to check with your web server administration as to what is happening with these emails on the mail server.

 a bunch of recommendations -

  1. email can be unreliable. you should store the submitted form data in an database table or a log file so that you have record of the form submissions.
  2. the form processing code should NOT copy variables to other variables for nothing. this is just a waste of typing. keep the form data as a set in a php array variable, then operate on elements in this array variable throughout the rest of the code.
  3. as a more advanced programming task, if you have more than 2-3 form fields, you should use a data-driven design and dynamically validate and process the form data.
  4. you need to trim all the input data before using it, mainly to detect if all white-space characters were entered. after you do item #2 on this list, you can accomplish this will one single line of code.
  5. you need to validate all the trimmed input data before using it, storing user/validation errors in an array using the field name as the main array index. 'required' fields must not be equal to an empty string and fields that must have a specific format, such as an email address, must be validated to insure they have that format.
  6. after the end of the validation logic, if there are no validation errors (the array holding the user/validation errors will be empty), use the form data.
  7. you need to apply htmlentities() to all the submitted form data, after validating it and before using it in an email or in form field values, to help prevent cross site scripting.
  8. you must test the return value from the mail() call. if it is a false value, setup a general failure message for the user and log all the relevant data from the request, such as - date/time, ip address, form data, ...
  9. the form fields should be 'sticky' and repopulate the field values upon any user/validation errors, so that the user doesn't need to keep reentering data over and over.

note: if there are user/validation errors, you would redisplay the form, therefore it should not be inside the else conditional for a post method form having been submitted.

if this stopped working, the most likely cause is that it is being used to send spam. by not validating the submitted email address (see item #5 on the above list) and putting the submitted value into the mail header, a spammer can send anything to anyone he wants through your mail server.

The form was working fine, I believe a small amount of code may have been removed before i inherited the site. I understand you would build this in a superior way. For now, I just want to make the form that is there work. On the front end, the form works well. The SMTP on the site works well, and other forms send fine. This form worked well before (I think some code was removed). The form hasn't stopped working because of spam. The server and domain reputation are good, as are all other emails being sent from the same site. Hopefully somebody can see something that is missing. Many thanks! 

<?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 you an official quote within 1 working day (normally much quicker!).</p>
						<p>Our bespoke handmade bunting is all made to order so we will also provide you our current lead-time. If you have any questions give us a call on 01749 850 991.</p>
						<p>For more decor please <a href="https://shop.eventflaghire.co.uk">visit our webshop</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 class="home-wrap flag-styles">
								<div class="center-big-flags center-big-flags-7">																																	
									<div class="flag-blueprint teal-hover">
										<div>
											<input type="radio" class="flag-style" value="New Leaf" name="flag-style" id="flag-style-new-leaf">
											<label for="flag-style-new-leaf" title="New Leaf">
											<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-timeout=2000>
												<img src="https://www.eventflaghire.co.uk/wp-content/uploads/2020/05/Festival-Flags-New-Leaf.png" alt="Festival Flags New Leaf" />
											</div>
											</label>
										</div>								
									</div>
									<div class="flag-blueprint turquoise-hover">
										<div>
											<input type="radio" class="flag-style" value="Silk & Ribbon" name="flag-style" id="flag-style-silk-and-ribbon">
											<label for="flag-style-silk-and-ribbon" title="Silk & Ribbon">
											<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-timeout=2000>
												<img src="https://www.eventflaghire.co.uk/wp-content/uploads/2020/05/Festival-Flags-Silk-Ribbon.png" alt="Festival Flags Silk & Ribbon" />
											</div>
											</label>
										</div>
									</div>
									<div class="flag-blueprint teal-hover">
										<div>
											<input type="radio" class="flag-style" value="Half Moon Petal" name="flag-style" id="flag-style-half-moon-petal">
											<label for="flag-style-half-moon-petal" title="Half Moon Petal">
											<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-timeout=2000>
												<img src="https://www.eventflaghire.co.uk/wp-content/uploads/2020/05/Festival-Flags-Half-Moon-Petal.png" alt="Festival Flags Half Moon Petal" />
											</div>
											</label>
										</div>
									</div>
									<div class="flag-blueprint turquoise-hover">
										<div>
											<input type="radio" class="flag-style" value="Indian Summer" name="flag-style" id="flag-style-indian-summer">							
											<label for="flag-style-indian-summer" title="Indian Summer">
											<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-timeout=2000>
												<img src="https://www.eventflaghire.co.uk/wp-content/uploads/2020/05/Festival-Flags-Indian-Summer.png" alt="Festival Flags Indian Summer" />
											</div>
											</label>
										</div>
									</div>
									<div class="flag-blueprint teal-hover">
										<div>
											<input type="radio" class="flag-style" value="Phoenix" name="flag-style" id="flag-style-phoenix">
											<label for="flag-style-phoenix" title="Phoenix">
											<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-timeout=2000>
												<img src="https://www.eventflaghire.co.uk/wp-content/uploads/2023/03/Phoenix-Festival-Flag-Blueprint.png" alt="Phoenix Festival Flag Blueprint" />
											</div>
											</label>
										</div>
									</div>
									<div class="flag-blueprint turquoise-hover">										
										<div>
											<input type="radio" class="flag-style" value="Bright Stripes" name="flag-style" id="flag-style-bright-stripes">
											<label for="flag-style-bright-stripes" title="Bright Stripes">
											<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-timeout=2000>
												<img src="https://www.eventflaghire.co.uk/wp-content/uploads/2020/05/Festival-Flags-Bright-Stripes.png" alt="Festival Flags Bright Stripes" />
											</div>
											</label>
										</div>
									</div>
									<div class="flag-blueprint teal-hover">
										<div>
											<input type="radio" class="flag-style" value="Calypso" name="flag-style" id="flag-style-calypso">
											<label for="flag-style-calypso" title="Calypso">
											<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-timeout=2000>
												<img src="https://www.eventflaghire.co.uk/wp-content/uploads/2023/03/Calypso-Flag-Blueprint-.png" alt="Calypso Flag Blueprint" />
											</div>
											</label>
										</div>
									</div>
								</div>
								<div class="home-wrap topTwoButtons clearBoth" style="overflow:hidden; margin-top:32px;">						
									<div class="inline-button">
										<input type="radio" class="flag-style" value="Choose for me" name="flag-style" id="flag-style-choose-for-me">
										<label for="flag-style-choose-for-me">I love them all, choose for me</label>
									</div>
								</div>								
							</div>
						</fieldset>										
					</div>
					
					<div id="package-step02" class="clearBoth teal-background flag-strip">					
						<fieldset class="package-section-title side-padding max-width-1000">
							<legend><strong>Step 2:</strong> Choose your colour palette</legend>
							<p>Get inspired by selecting one of our beautiful pre-set palettes below.</p>
							<ul class="palettes">
								<li class="swatch-festival-mix">
									<input type="radio" class="palette" value="Festival Mix" name="palette" id="palette-festival-mix">
									<label for="palette-festival-mix" title="Festival Mix">
									<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-speed="500" data-cycle-timeout=1000>
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/festival-mix.svg" alt="Festival Mix">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Festival-Mix-Rollover.jpg" alt="Festival Mix">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Festival-Mix-Rollover-02.jpg" alt="Festival Mix">
									</div>
									</label>
								</li>
								<li class="swatch-warm-hues">
									<input type="radio" class="palette" value="Warm Hues" name="palette" id="palette-warm-hues">
									<label for="palette-warm-hues" title="Warm Hues">
									<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-speed="500" data-cycle-timeout=1000>
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/warm-hues.svg" alt="Warm Hues">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Warm-Hues-Rollover.jpg" alt="Warm Hues">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Warm-Hues-Rollover-02.jpg" alt="Warm Hues">
									</div>
									</label>
								</li>
								<li class="swatch-under-the-sea">
									<input type="radio" class="palette" value="Under the Sea" name="palette" id="palette-under-the-sea">
									<label for="palette-pastels" title="Under the Sea">
									<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-speed="500" data-cycle-timeout=1000>
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/under-the-sea.svg" alt="Under the Sea">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Under-the-Sea-Rollover.jpg" alt="Under the Sea">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Under-the-Sea-Rollover-02.jpg" alt="Under the Sea">
									</div>
									</label>
								</li>
								<li class="swatch-pastels">
									<input type="radio" class="palette" value="Pastels" name="palette" id="palette-pastels">
									<label for="palette-pastels" title="Pastels">
									<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-speed="500" data-cycle-timeout=1000>
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/pastels.svg" alt="Pastels">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Pastels-Rollover.jpg" alt="Pastels">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Pastels-Rollover-02.jpg" alt="Pastels">
									</div>
									</label>
								</li>
								<li class="swatch-white-ivory">
									<input type="radio" class="palette" value="White &amp; Ivory" name="palette" id="palette-white-ivory">
									<label for="palette-white-ivory" title="White &amp; Ivory">
									<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-speed="500" data-cycle-timeout=1000>
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/white-ivory.svg" alt="White &amp; Ivory">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/White-Ivory-Rollover.jpg" alt="White &amp; Ivory">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/White-Ivory-Rollover-02.jpg" alt="White &amp; Ivory">
									</div>
									</label>
								</li>
								<li class="swatch-multicolour-rainbow">
									<input type="radio" class="palette" value="Multicolour Rainbow" name="palette" id="palette-multicolour-rainbow">
									<label for="palette-multicolour-rainbow" title="Multicolour Rainbow">
									<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-speed="500" data-cycle-timeout=1000>
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/multicolour-rainbow.svg" alt="Multicolour Rainbow">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Multicolour-Rainbow-Rollover.jpg" alt="Multicolour Rainbow">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Multicolour-Rainbow-Rollover-02.jpg" alt="Multicolour Rainbow">
									</div>
									</label>
								</li>
								<li class="swatch-multicolour-warm-hues">
									<input type="radio" class="palette" value="Multicolour Warm Hues" name="palette" id="palette-multicolour-warm-hues">
									<label for="palette-multicolour-warm-hues" title="Multicolour Warm Hues">
									<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-speed="500" data-cycle-timeout=1000>
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/multicolour-warm-hues.svg" alt="Multicolour Warm Hues">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Multicolour-Warm-Hues-Rollover.jpg" alt="Multicolour Warm Hues">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Multicolour-Warm-Hues-Rollover-02.jpg" alt="Multicolour Warm Hues">
									</div>
									</label>
								</li>
								<li class="swatch-multicolour-cool-hues">
									<input type="radio" class="palette" value="Multicolour Cool Hues" name="palette" id="palette-multicolour-cool-hues">
									<label for="palette-multicolour-cool-hues" title="Multicolour Cool Hues">
									<div class="cycle-slideshow" data-cycle-fx=fadeout data-cycle-speed="500" data-cycle-timeout=1000>
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/multicolour-cool-hues.svg" alt="Multicolour Cool Hues">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Multicolour-Cool-Hues-Rollover.jpg" alt="Multicolour Cool Hues">
										<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/swatches/rollovers/Multicolour-Cool-Hues-Rollover-02.jpg" alt="Multicolour Cool Hues">
									</div>
									</label>
								</li>																								
							</ul>
						</fieldset>					
					</div>
						
					<div id="package-step03" class="clearBoth flag-strip">
						<fieldset class="package-section-title side-padding max-width-1000">
							<legend><strong>Step 3:</strong> How many flags do you need?</legend>
							<div class="inline-buttons">						
								<div class="inline-button">
									<input type="radio" class="number-of-flags" value="6 flags + 25m bunting" name="no-of-flags" id="flags-6">
									<label for="flags-6">6 FLAGS <span>+ 25m bunting</span></label> <span><strong>&pound;235 (ex VAT)</strong><br>&pound;282 (inc VAT)</span>
								</div>						
								<div class="inline-button">
									<input type="radio" class="number-of-flags" value="10 flags + 40m bunting" name="no-of-flags" id="flags-10">
									<label for="flags-10">10 FLAGS <span>+ 40m bunting</span></label> <span><strong>&pound;340 (ex VAT)</strong><br>&pound;408 (inc VAT)</span>
								</div>
								<div class="inline-button">
									<input type="radio" class="number-of-flags" value="20 flags + 50m bunting" name="no-of-flags" id="flags-20">
									<label for="flags-20">20 FLAGS <span>+ 50m bunting</span></label> <span><strong>&pound;565 (ex VAT)</strong><br>&pound;678 (inc VAT)</span>
								</div>
								<div class="inline-button">
									<input type="radio" class="number-of-flags" value="25 flags + 100m bunting" name="no-of-flags" id="flags-25">
									<label for="flags-25">25 FLAGS <span>+ 100m bunting</span></label> <span><strong>&pound;750 (ex VAT)</strong><br>&pound;900 (inc VAT)</span>
								</div>
							</div>	
						</fieldset>
					</div>
					
					<div id="package-step04" class="clearBoth teal-background flag-strip">
						<fieldset class="teal-background package-section-title side-padding max-width-1000">
							<legend><strong>Step 4:</strong> Would you like to add additional bunting?</legend>
							<div class="home-wrap topTwoButtons" style="overflow:hidden;">						
								<div class="col-half">						
									<div class="inline-button">
										<input type="radio" class="add-bunting" value="Yes" name="add-bunting" id="add-bunting-yes">
										<label for="add-bunting-yes">YES</label>
									</div>
								</div>
								<div class="col-half">
									<div class="inline-button">
										<input type="radio" class="add-bunting" value="No" name="add-bunting" id="add-bunting-no">
										<label for="add-bunting-no">NO</label>
									</div>
								</div>													
							</div>
							
							<fieldset class="package-section-title side-padding max-width-1000">
								<legend>Is your bunting for inside or outside use?</legend>
								<div class="home-wrap topTwoButtons">						
									<div class="col-half">					
										<div class="inline-button">
											<input type="radio" value="Inside" name="bunting-location" id="bunting-location-inside">
											<label for="bunting-location-inside">INSIDE</label>
										</div>
									</div>
									<div class="col-half">
										<div class="inline-button">
											<input type="radio" value="Outside" name="bunting-location" id="bunting-location-outside">
											<label for="bunting-location-outside">OUTSIDE</label>
										</div>			
									</div>																	
								</div>									
							</fieldset>		
							
							<div id="extra-bunting-options">								
								<fieldset class="package-section-title side-padding max-width-1000">
									<legend>Choose your length in metres</legend>
									<div class="bunting-length">
										<label for="length">Length</label>
										<input class="text" type="number" name="length" id="length" min="10" step="10" value="20" onKeyDown="return false">
									</div>
									<div class="bunting-price">
										<p>&pound;<span class="price">1.50</span> + VAT <small>per metre</small></p>
									</div>
								</fieldset>																
							</div>
							
							<fieldset class="teal-background package-section-title side-padding max-width-1000">
								<legend>Would you like a refolding service?</legend>
								<div class="home-wrap topTwoButtons">						
									<div class="col-half">						
										<div class="inline-button">
											<input type="radio" class="bunting-refolding" value="Yes" name="bunting-refolding" id="bunting-refolding-yes">
											<label for="bunting-refolding-yes">YES</label> <span>We offer a refolding service for 40p (+ VAT) per metre if required.</span>
										</div>
									</div>
									<div class="col-half">
										<div class="inline-button">
											<input type="radio" class="bunting-refolding" value="No" name="bunting-refolding" id="bunting-refolding-no">
											<label for="bunting-refolding-no">NO</label> <span>Return the bunting unfolded, we will provide instructions.</span>
										</div>
									</div>													
								</div>
							</fieldset>														
							
						</fieldset>															
					</div>
					
					<div id="package-step05" class="clearBoth flag-strip">
						<fieldset class="package-section-title side-padding max-width-1000">
							<legend><strong>Step 5:</strong> Choose your delivery option</legend>
							<div class="home-wrap topTwoButtons">						
								<div class="col-half">					
									<div class="inline-button">
										<input type="radio" class="delivery-option" value="Deliver" name="delivery-option" id="delivery-option-deliver">
										<label for="delivery-option-deliver">DELIVER</label> <span>Delivery and return is via next day courier.</span>
									</div>
								</div>
								<div class="col-half">
									<div class="inline-button">
										<input type="radio" class="delivery-option" value="Collection" name="delivery-option" id="delivery-option-collection">
										<label for="delivery-option-collection">COLLECT</label> <span>Collection is from our office in Bruton, Somerset. Return next day courier.</span>
									</div>			
								</div>																	
							</div>
							<div id="deliveryAddressType" class="home-wrap topTwoButtons" style="margin-top: 20px;">						
								<div class="col-half">					
									<div class="inline-button">
										<input type="radio" class="delivery-address-type" value="Residential" name="delivery-address-type" id="delivery-address-type-residential">
										<label for="delivery-address-type-residential">RESIDENTIAL</label> <span>Residential addresses will incur a &pound;10 surcharge each way for orders with flag poles.</span>
									</div>
								</div>
								<div class="col-half">
									<div class="inline-button">
										<input type="radio" class="delivery-address-type" value="Business" name="delivery-address-type" id="delivery-address-type-business">
										<label for="delivery-address-type-business">BUSINESS</label>
									</div>			
								</div>																	
							</div>	
						</fieldset>	
					</div>
					
					<div id="package-step06" class="clearBoth teal-background flag-strip">					
						<fieldset class="package-section-title side-padding max-width-1000">
							<legend><strong>Step 6:</strong> Enter your contact details</legend>
							
							<div class="your-details">
								<label for="your-first-name">Your first name*</label>
								<input type="text" name="your-first-name" id="your-first-name" required>
							
								<label for="your-surname">Your surname*</label>
								<input type="text" name="your-surname" id="your-surname" required>
								
								<label for="your-email">Your email address*</label>
								<input type="email" name="your-email" id="your-email" required>
								
								<label for="your-phone">Your phone number*</label>
								<input type="tel" name="your-phone" id="your-phone" required>										
							</div>
						</fieldset>						
					</div>
					
					<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 commences on a Wednesday and finishes on a Tuesday. If the rental period incorporates 2 weekends this a 2 week rental but charge a 1.5 times rental fee.</p>
										<p>Most events take place on a weekend. We aim to despatch on a Wednesday for arrival on a Thursday to be erect on a Friday for an event on either Friday, Saturday or Sunday. We then collect on a Monday and the items are returned to us on a Tuesday. They are then unpacked, checked and repacked to be despatched again on a Wednesday to a different destination.</p>
										<p>Any collections on a Friday are delivered on a Monday and therefore deemed as a lost weekend rental. Couriers do not work on Sundays but can deliver on a Saturday for an additional fee.</p>
										<p>We can be flexible with a Tuesday either sending out a day early or collecting a day later but at the height of season we are dependent on all our stock being returned when agreed and without damage, or wet or dirty which leaves us little time to rectify these problems between orders.</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 that someone will be available to sign for the delivery a couple of days before your event date and the next working day after. This should not be a venue/field that a courier would not be able to deliver to. Delivery and collection addresses can be different.</p>
										</div>
									</div>

									<label for="event-contact">Contact name &amp; number for delivery (if different)</label>
									<input type="text" name="event-contact" id="event-contact">
								</div>
								
								<label for="additional-comments">Any additional comments/requirements?</label>
								<p><small>For example, let us know if you require a base for your flags.</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();

 

  • Solution

As an aside, when I see code like this....

 

$buntingRefolding = $_POST['bunting-refolding'];                    
$firstName = $_POST['your-first-name'];
$surname = $_POST['your-surname'];
$emailAddress = $_POST['your-email'];
//etc

 

I always wonder why.  Did they not understand PHP variables?  How to interpolate an array? 

Well at any rate, before we can even begin to consider the issue, you need to define what "stopped working" means.   If it means that you used to get emails and you now don't, and nothing in the code has changed, the most likely culprit is that something in your hosting setup changed so that it no longer allows emails to be sent from your server (or they are being spam filtered because you don't have the things needed for a server and domain to allow.

This code uses the mail() function, which is the lowest common denominator for sending mail, and is reliant on other MTA configuration in the OS.  There isn't a lot of visibility into what happens once the mail is dropped off to the MTA, which is a big reason that more sophisticated email libraries exist.  I don't know how old this code is, but wordpress has its own mailing function wp_mail() which wasn't used, so when you say that the other mail works, I would check that those routines were written the same way.  They might be using wp_mail() which wraps the phpmailer library.

On 2/10/2024 at 10:43 PM, gizmola said:

As an aside, when I see code like this....

 

$buntingRefolding = $_POST['bunting-refolding'];                    
$firstName = $_POST['your-first-name'];
$surname = $_POST['your-surname'];
$emailAddress = $_POST['your-email'];
//etc

 

I always wonder why.  Did they not understand PHP variables?  How to interpolate an array? 

Well at any rate, before we can even begin to consider the issue, you need to define what "stopped working" means.   If it means that you used to get emails and you now don't, and nothing in the code has changed, the most likely culprit is that something in your hosting setup changed so that it no longer allows emails to be sent from your server (or they are being spam filtered because you don't have the things needed for a server and domain to allow.

This code uses the mail() function, which is the lowest common denominator for sending mail, and is reliant on other MTA configuration in the OS.  There isn't a lot of visibility into what happens once the mail is dropped off to the MTA, which is a big reason that more sophisticated email libraries exist.  I don't know how old this code is, but wordpress has its own mailing function wp_mail() which wasn't used, so when you say that the other mail works, I would check that those routines were written the same way.  They might be using wp_mail() which wraps the phpmailer library.

Thanks Gizmola,

I changed the mail() function to wp_mail() and everything is working again. The form is good enough for now until the site is rebuilt. 

Thanks everyone for your help! It's really appreciated.

Best wishes,

Lanx

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.