Adding Custom fields - HTML vs PHP

2 replies · opened Jul 6, 2016

Rrenegade018Jul 6, 2016

I am trying to add "custom" fields to the canvas website + phpmailer.

As you can see on the picture.

I need to add fields for "MLS NUMBER", "INSPECTION DATE", "YEAR OF CONSTRUCTION" and so on... (fields work and can be filled in.... BUT: When I receive the email, only the standard fields are in the email (name / phone / email / subjet / message)

What needs to be added to sendemail.php so every field is included in the email?

***I've created personalised "id" and "name" for earch field. (was that good?)

Rrenegade018Jul 6, 2016

<form class="nobottommargin" id="template-contactform" name="template-contactform" action="include/sendemail.php" method="post">

						&lt;div class="col_half"&gt;
							&lt;label for="template-contactform-name"&gt;Nom &lt;small&gt;*&lt;/small&gt;&lt;/label&gt;
							&lt;input type="text" id="template-contactform-name" name="template-contactform-name" value="" class="sm-form-control required" /&gt;
						&lt;/div&gt;

						&lt;div class="col_half col_last"&gt;
							&lt;label for="template-contactform-email"&gt;Courriel &lt;small&gt;*&lt;/small&gt;&lt;/label&gt;
							&lt;input type="email" id="template-contactform-email" name="template-contactform-email" value="" class="required email sm-form-control" /&gt;
						&lt;/div&gt;

						&lt;div class="clear"&gt;&lt;/div&gt;

						&lt;div class="col_half"&gt;
							&lt;label for="template-contactform-phone"&gt;Téléphone &lt;small&gt;*&lt;/small&gt;&lt;/label&gt;
							&lt;input type="text" id="template-contactform-phone" name="template-contactform-phone" value="" class="sm-form-control required" /&gt;
						&lt;/div&gt;

						&lt;div class="clear"&gt;&lt;/div&gt;

						&lt;div class="fancy-title title-dotted-border"&gt;
							&lt;h4&gt;Information générale&lt;/h4&gt;
						&lt;/div&gt;
						
						&lt;div class="col_half"&gt;
							&lt;label for="template-contactform-mls"&gt;Numéro MLS&lt;/label&gt;
							&lt;input type="text" id="template-contactform-name" name="template-contactform-name" value="" class="sm-form-control" /&gt;
						&lt;/div&gt;

						&lt;div class="col_half col_last"&gt;
							&lt;label for="template-contactform-courtier"&gt;Courtier (nom / prénom)&lt;/label&gt;
							&lt;input type="text" id="template-contactform-courtier" name="template-contactform-courtier" value="" class="sm-form-control" /&gt;
						&lt;/div&gt;

						&lt;div class="clear"&gt;&lt;/div&gt;

						&lt;div class="col_half"&gt;
							&lt;label for="template-contactform-inspection"&gt;Date d'inspection&lt;/label&gt;
							&lt;input type="text" id="template-contactform-inspection" name="template-contactform-inspection" value="" class="sm-form-control" /&gt;
						&lt;/div&gt;

						&lt;div class="col_half col_last"&gt;
							&lt;label for="template-contactform-annee"&gt;Anne de construction&lt;/label&gt;
							&lt;input type="text" id="template-contactform-annee" name="template-contactform-annee" value="" class="sm-form-control" /&gt;
						&lt;/div&gt;

						&lt;div class="clear"&gt;&lt;/div&gt;

						&lt;div class="col_half"&gt;
							&lt;label for="template-contactform-typemaison"&gt;Type de maison&lt;/label&gt;
							&lt;input type="text" id="template-contactform-typemaison" name="template-contactform-typemaison" value="" class="sm-form-control" /&gt;
						&lt;/div&gt;

						&lt;div class="col_half col_last"&gt;
							&lt;label for="template-contactform-dimension"&gt;Dimension de la maison&lt;/label&gt;
							&lt;input type="text" id="template-contactform-dimension" name="template-contactform-dimension" value="" class="sm-form-control" /&gt;
						&lt;/div&gt;

						&lt;div class="clear"&gt;&lt;/div&gt;

						&lt;div class="col_half"&gt;
								&lt;label for="template-contactform-garage"&gt;Type de garage&lt;/label&gt;
								&lt;select id="template-contactform-garage" name="template-contactform-garage" class="sm-form-control"&gt;
									&lt;option value=""&gt;-- Faites votre choix --&lt;/option&gt;
									&lt;option value="aucun"&gt;Aucun&lt;/option&gt;
									&lt;option value="détaché"&gt;Détacheé&lt;/option&gt;
									&lt;option value="attaché"&gt;Attaché&lt;/option&gt;
									&lt;option value="intrégré"&gt;Intrégré&lt;/option&gt;
									&lt;option value-"autre"&gt;Autre&lt;/option&gt;
								&lt;/select&gt;
							&lt;/div&gt;

						&lt;div class="clear"&gt;&lt;/div&gt;

						&lt;div class="fancy-title title-dotted-border"&gt;
							&lt;h4&gt;Nouvelle résidence&lt;/h4&gt;
						&lt;/div&gt;

						&lt;div class="col_half"&gt;
							&lt;label for="template-contactform-ville"&gt;Ville de la nouvelle maison&lt;/label&gt;
							&lt;input type="text" id="template-contactform-ville" name="template-contactform-ville" value="" class="sm-form-control" /&gt;
						&lt;/div&gt;

						&lt;div class="col_half col_last"&gt;
							&lt;label for="template-contactform-dimensionneuve"&gt;Dimension de la maison&lt;/label&gt;
							&lt;input type="text" id="template-contactform-dimensionneuve" name="template-contactform-dimensionneuve" value="" class="sm-form-control" /&gt;
						&lt;/div&gt;

						&lt;div class="clear"&gt;&lt;/div&gt;

						&lt;div class="fancy-title title-dotted-border"&gt;
							&lt;h4&gt;Rénovation ou agrandissement&lt;/h4&gt;
						&lt;/div&gt;

						&lt;div class="col_full "&gt;
							&lt;h6&gt;* Une visite des lieux doit être effectuée afin de bien évaluer vos besoins et la travail à effectuer.&lt;/h6&gt;
						&lt;/div&gt;

						&lt;div class="col_half"&gt;
							&lt;label for="template-contactform-rencontre"&gt;date de rencontre souhaitée&lt;/label&gt;
							&lt;input type="text" id="template-contactform-rencontre" name="template-contactform-rencontre" value="" class="sm-form-control" /&gt;
						&lt;/div&gt;
			

						&lt;div class="clear"&gt;&lt;/div&gt;

						&lt;div class="col_full"&gt;
							&lt;label for="template-contactform-message"&gt;Informations supplémentaires &lt;small&gt;*&lt;/small&gt;&lt;/label&gt;
							&lt;textarea class="required sm-form-control" id="template-contactform-message" name="template-contactform-message" rows="6" cols="30"&gt;&lt;/textarea&gt;
						&lt;/div&gt;

						&lt;div class="col_full hidden"&gt;
							&lt;input type="text" id="template-contactform-botcheck" name="template-contactform-botcheck" value="" class="sm-form-control" /&gt;
						&lt;/div&gt;

						&lt;div class="col_full"&gt;
							&lt;button class="button button-3d nomargin" type="submit" id="template-contactform-submit" name="template-contactform-submit" value="submit"&gt;Envoyer&lt;/button&gt;
						&lt;/div&gt;

					&lt;/form&gt;
SSemicolon WebSTAFFJul 7, 2016

Hello,

This is Definitely Possible but you will need to Edit the include/sendemail.php File to Add the Custom Fields. There are 3 Steps to configure this in the include/sendemail.php File:

  1. Find the following code and duplicate it to add the New Field:
$name = isset( $_POST['template-contactform-name'] ) ? $_POST['template-contactform-name'] : '';

Example:

$newfield = isset( $_POST['template-contactform-newfield'] ) ? $_POST['template-contactform-newfield'] : '';

Make sure that the template-contactform-newfield is same as the Form Input’s name attribute in the HTML.

  1. Now, find the following code just a few lines below and duplicate it to add the New Field:
$name = isset($name) ? "Name: $name

" : '';

Example:

$newfield = isset($newfield) ? "New Field: $newfield

" : '';
  1. You now simply need to Add the New Field to the following code:
$body = "$name $email $phone $service $message $referrer";

Example:

$body = "$name $email $phone $newfield $service $message $referrer";

This will definitely work fine. 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