Mail problems

4 replies·opened Sep 15, 2018
N
NicoBootsSep 15, 2018

I have just published my new web site (www.duepadroni.it). On the index pages for all four languages I have used the contact form which in itself works fine. I receive the messages in my IN-box. The only problem I have is that the form also contains a date range, and this date range is not displayed in the email that I receive. Below is the HTML code for the form that I have used.

<form class="nobottommargin" id="template-contactform" name="template-contactform" action="include/sendemail.php" method="post">
                                <a id="Contact"></a>
    
                                    
    
                                    <div class="col_one_third">
                                        <label for="template-contactform-name">Naam <small>*</small></label>
                                        <input type="text" id="template-contactform-name" name="template-contactform-name" value="" class="sm-form-control required" />
                                    </div>
    
                                    <div class="col_one_third">
                                        <label for="template-contactform-email">Email <small>*</small></label>
                                        <input type="email" id="template-contactform-email" name="template-contactform-email" value="" class="required email sm-form-control" />
                                    </div>
    
                                    <div class="col_one_third col_last">
                                        <label for="template-contactform-phone">Telefoon</label>
                                        <input type="text" id="template-contactform-phone" name="template-contactform-phone" value="" class="sm-form-control" />
                                    </div>
    
                                    <div class="clear"></div>
                                    
                                     
    
                                    <div class="col_two_third">
                                        <label for="template-contactform-subject">Onderwerp <small>*</small></label>
                                        <input type="text" id="template-contactform-subject" name="template-contactform-subject" value="" class="required sm-form-control" />
                                    </div>
    
                                    <div class="col_one_third col_last">
                                        <label for="template-contactform-service">Betreft</label>
                                        <select id="template-contactform-service" name="template-contactform-service" class="sm-form-control">
                                            <option value="">-- Maak uw keuze --</option>
                                            <option value="Algemeen">Algemeen</option>
                                            <option value="Loggione">Appartement Loggione</option>
                                            <option value="Cantinetta">Appartement Cantinetta</option>
                                      	</select>
                                    </div>
                                    <div class="col-sm-6 bottommargin-sm">
                                    	<div class="input-daterange travel-date-group bottommargin-sm">
                                      
                                        <label for="template-contactform-daterange">periode</label>
                                        <div class="input-daterange input-group">
                                          <span class="input-group-addon">van</span>
                                          <input type="text" id="template-contactform-van" value="" class="sm-form-control tleft" placeholder="DD/MM/YYYY">
                                          <span class="input-group-addon">tot</span>
                                          <input type="text" id="template-contactform-tot" value="" class="sm-form-control tleft" placeholder="DD/MM/YYYY">
                                        </div>
                                      </div>
                                    </div>
    
                                    <div class="clear"></div>
    
                                    <div class="col_full">
                                        <label for="template-contactform-message">Bericht <small>*</small></label>
                                        <textarea class="required sm-form-control" id="template-contactform-message" name="template-contactform-message" rows="6" cols="30"></textarea>
                                    </div>
    
                                    <div class="col_full hidden">
                                        <input type="text" id="template-contactform-botcheck" name="template-contactform-botcheck" value="" class="sm-form-control" />
                                    </div>
    
                                    <div class="col_full">
    
                                        <script src="https://www.google.com/recaptcha/api.js" async defer></script>
                                        <div class="g-recaptcha" data-sitekey="6LeAcWQUAAAAANyLIqc7DbvNvJ8cpqyehDhIbntz"></div>
    
                                    </div>
    
                                    <div class="col_full">
                                        <button class="button button-3d nomargin" type="submit" id="template-contactform-submit" name="template-contactform-submit" value="submit">Verstuur bericht</button>
                                    </div>
    
                                </form>

I have also made some changes to the seandmail.php file as instructed in the manual:

if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
	if( $_POST['template-contactform-email'] != '' ) {

		$name = isset( $_POST['template-contactform-name'] ) ? $_POST['template-contactform-name'] : '';
		$email = isset( $_POST['template-contactform-email'] ) ? $_POST['template-contactform-email'] : '';
		$phone = isset( $_POST['template-contactform-phone'] ) ? $_POST['template-contactform-phone'] : '';
		$service = isset( $_POST['template-contactform-service'] ) ? $_POST['template-contactform-service'] : '';
		$van = isset( $_POST['template-contactform-van'] ) ? $_POST['template-contactform-van'] : '';
		$tot = isset( $_POST['template-contactform-tot'] ) ? $_POST['template-contactform-tot'] : '';
		
		$daterange = isset( $_POST['template-contactform-daterange'] ) ? $_POST['template-contactform-name'] : '';
		$subject = isset( $_POST['template-contactform-subject'] ) ? $_POST['template-contactform-subject'] : '';
		$message = isset( $_POST['template-contactform-message'] ) ? $_POST['template-contactform-message'] : '';

		$subject = isset($subject) ? $subject : 'New Message From Contact Form';

		$botcheck = $_POST['template-contactform-botcheck'];

		if( $botcheck == '' ) {

			$mail->SetFrom( $email , $name );
			$mail->AddReplyTo( $email , $name );
			foreach( $toemails as $toemail ) {
				$mail->AddAddress( $toemail['email'] , $toemail['name'] );
			}
			$mail->Subject = $subject;

			$name = isset($name) ? "Name: $name

" : '';
			$email = isset($email) ? "Email: $email

" : '';
			$phone = isset($phone) ? "Phone: $phone

" : '';
			$service = isset($service) ? "Service: $service

" : '';
			$van = isset($name) ? "van: $van

" : '';
			$tot = isset($name) ? "tot: $tot

" : '';
			$daterange = isset($newfield) ? "Date Range: $daterange

" : '';
			$message = isset($message) ? "Message: $message

" : '';

			$referrer = $_SERVER['HTTP_REFERER'] ? '

This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';

			$body = "$name $email $phone $service $van $tot $daterange $message $referrer";

The result what I see in my mail is:

Name: nico boots
Email: boots@planet.nl
Phone: 09876543123
Service: Loggione
van:
tot:
Message: testen

As you can see dates are not displayed. Can you tell me how to solve this?

This Form was submitted from: http://www.duepadroni.it/indexIT.php

N
NicoBootsSep 19, 2018

knock, knock... somebody home? I appreciate a reply....

S
SemiColonWebSTAFFSep 20, 2018

Hello,

We have checked out your Codes and the issue seems to be with the HTML Input Fields which do not include the name Attribute required for the PHP to capture the Values. Make sure your Fields look like this:

<input type="text" id="template-contactform-van" name="template-contactform-van" value="" class="sm-form-control tleft" placeholder="DD/MM/YYYY">

This should fix the issue. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

N
NicoBootsSep 21, 2018

I have made the changes in the code that you have suggested, but I still do not receive in my mail the dates that I have selected in the date range field. Any suggestion how to solve this?

A second problem which I have not mentioned yet is that the user does not get a message that the form is successfully submitted (or failed). Do I have to adjust the sendmail.php file to achieve this?

S
SemiColonWebSTAFFSep 24, 2018

Hello,

We have checked out your Codes Online but we can see that there is no name added to the Form Inputs. Additionally, we can also see that the Default Code Structure of the Forms have not been followed with the .form-process Element not added. Also, we can see that there are several HTML Validation errors on your Page: https://validator.w3.org/nu/?doc=http%3A%2F%2Fwww.duepadroni.it%2FindexIT.php .

Consider fixing the Errors as mentioned above and please let us know again. Additionally, please consider following this article completely: http://support.semicolonweb.com/forums/topic/adding-custom-fields-html-vs-php/#post-2261 .

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard