First create your field in html file with a new name, feel free to change the margins in order to make it look right.
<input type="text" placeholder="Phone number" name="phone_field" id="phone_field" class="fillable-field required custom-reveal"> <!-- add a custom field --> <input type="text" placeholder="My field" name="your_custom_field" id="your_custom_field" class="fillable-field required custom-reveal"> <input type="text" name="prCode_field" id="prCode_field" class="fillable-field l-hidden required custom-reveal products-code-list"> <input type="submit" value="Send" class="button submit-btn checkout custom-reveal">
Next in sendmail.php file define and validate it like others:
$name_field = check_input($_POST["name_field"]); $mail_field = check_input($_POST["mail_field"]); $phone_field = check_input($_POST["phone_field"]); $prod_list = check_input($_POST["prCode_field"]); $subject_field = check_input($_POST["subject_field"]); $message_field = check_input($_POST["message_field"]); $your_field_name = check_input($_POST["your_field_name"]);
Make sure to fill the template with your new field:
if ($message_field!=="") { $subject = "Callback! From the site -Triablo- was sent an message!"; $message = file_get_contents('templates/message.html'); // Fill form (message form template) $message = str_replace('{{ subject }}', $subject_field, $message); $message = str_replace('{{ name }}', $name_field, $message); $message = str_replace('{{ mail }}', $mail_field, $message); $message = str_replace('{{ message }}', $message_field, $message); $message = str_replace('{{ fieldname }}', $your_custom_field, $message); } else { $form = 'product-form'; $subject = "Client order! From the site -Triablo- was sent an order!"; $message = file_get_contents('templates/mail.html'); // Fill form (products form template) $message = str_replace('{{ name }}', $name_field, $message); $message = str_replace('{{ mail }}', $mail_field, $message); $message = str_replace('{{ phone }}', $phone_field, $message); $message = str_replace('{{ fieldname }}', $your_custom_field, $message); /*...*/ }
If your field is from checkout form, find "mail.html" template in templates folder and add a placeholder for your field:
<tr> <td style="padding: 7px 40px 6px 40px;"> <table class="content" style="max-width: 600px; word-break: break-word;" width="100%" align="center" cellpadding="0" cellspacing="0"> <tr> <td style="vertical-align: top" width="63px">Label:</td> <td style="color: #42c3d6;">{{ fieldname }}</td> </tr> </table> </td> </tr>
And if you want to add some fields to contact form, do the same in the "message.html" template that's located in templates folder.