11. Contact Form
In this section, we'll learn how to create the basic contact form, and how to set it send mail to your email address using the mail.php file. Here is a basic form markup:
Contact Formdiv class="anita-contact-form-wrap" form action="mail.php" method="post" class="anita-contact-form" data-fill-error="Please, fill out the contact form." div class="anita-grid anita-grid-small-gap anita-grid--3cols anita-grid--tablet-1col" input type="text" id="name" name="name" placeholder="Your Name" required input type="email" id="email" name="email" placeholder="Your Email" required input type="tel" id="phone" name="phone" placeholder="Your Phone" required /div textarea id="message" name="message" placeholder="Your Message" required /textarea div class="anita-contact-form__footer" div class="anita-contact-form__submit" input type="submit" value="Send Message" /div div class="anita-contact-form__response" /div /div /form /div
Now, to make all things work, you should edit the mail.php file and specify your email address in the $mail_to variable.
<?php * * Author: Shadow Themes * Author URL: https://shadow-themes.comif ( $_SERVER["REQUEST_METHOD"] =="POST" ) { # Replace this email with your email address$mail_to = "yourmail@example.com"; ... } ?>
Please note that this is a very simple basic contact form. There is no captcha or any serious spam protection. To secure your form, you should find third-party solutions. For example, here you can find the information about the reCaptcha by Google https://www.google.com/recaptcha/