WordPress Tutorials

How to Design WordPress Contact Form?

The sole purpose of putting a website on World Wide Web is to make yourself or business reachable to others. For this reason, we are using different mechanisms and strategies. One of the fundamental ways of staying reachable to viewers is to have a contact form on your website. Due to the important role it plays contact form designing has became an integral part of web design.

Create WordPress Contact Form Manually

You can create and manage contact forms on your site in two ways – with coding it all yourself and by using the plugins. First we shall look at the coding aspects. Follow below if you plan to create your WordPress contact form. This code will create a HTML form and validate the functions with php scripts. We recommend you try coding yourself if you are seasoned with coding. Beginners can still benefit from such coding attempts as contact form validation in php is requires basic understandings. Here we go:


<?php
$nameError = $emailError = $messageError = "";
$name????? = $email = $message = "";
If ($_SERVER["REQUEST_METHOD"] == "POST") {
If (empty($_POST["name"])) {
$nameError = "Name is required";
} else {
$name = test_input($_POST["name"]);
If (!preg_match("/^[a-zA-Z ]*$/", $name)) {
$nameError = "Only letters and white space allowed";
}
}
If (empty($_POST["email"])) {
$emailError = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
If (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailError = "Invalid email format";
}
}
If (empty($_POST["message"])) {
$message = "";
} else {
$message = test_input($_POST["message"]);
}
}
Function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
Return $data;
}
?>
<h2>Script for simple form</h2>
<p><span class="error">* required field.</span></p>
<form method="post" action="<?php
echo htmlspecialchars($_SERVER["PHP_SELF"]);
?>">
Name: <input type="text" name="name">
<span class="error">* <?php
echo $nameError;
?></span>
E-mail: <input type="text" name="email">
<span class="error">* <?php
echo $emailError;
?></span>
Message: <input type="text" name="website">
<span class="error"><?php
echo $messageError;
?></span>
<input type="submit" name="submit" value="Submit">
</form>
<?php
echo "<h2>Your Input:</h2>";
echo $name;
echo $email;
echo $comment;
?>
</body>
</html>

The above code will create a form with name, email and comment information. If any field gets unsupported input it will generate error message. The message will be through to your server if all conditions are met.

Best WordPress Contact Form Plugin

Alternative to above code is using the plugins. WordPress is famous for the availability of numerous functional plugins that add to the performance aspect of your portal. Here we are reviewing few top rated WordPress contact form plugins for you.

Contact Form 7: The Contact Form 7 is a popular contact form plugin for your WordPress website that lets you customize the form per your need and easy to integrate with your website. It follows simple markup style and the submission is Ajax powered, spam protection enabled and has CAPTCHA activated. It will support all WordPress 3.8 and higher versions. You can easily install the Contact Form 7 plugin from your plugins directory search and after installing it click to activate it.

WordFence: The WordFence is another popular plugin which is actually available to protect your website with enhanced security features. The advantage of using it is the plugin will add up to your communication protocol and make sure that nothing gets inside through the contact system. It is labeled as to be an enterprise class security and performance optimizer solution for your website. This plugin comes for free and has two factors authentication.

Contact Form: The Contact Form is another plugin that you can try. It is very simple to use and does not offer much complexities. The free plugin lets your users and viewers give your feedback on site. Once installed and activated you need to manually select which fields you require on the form and then it will be all ready to go. Such customization or selection of form fields come with other plugins too.

Easy Contact Forms: The Easy Contact Forms is yet another plugin that can make your works easier. It is noted as a visitor friendly plugin for contact forms that is easy to build and supports different fields. Users usually get lots of customization tools once they install the plugin and activate it. It too has spam guard system and multiple data validation layers which make it a reliable plugin.

In designing and deciding about contact forms for your WordPress website it is important that you consider your security aspects. Contact forms can work as a vent hole on your site that directly gives access to your server. Therefore always consider such an arrangement where your viewers will have to pass through different authentication processes whether it is CAPTCHA or something else. If you believe to deliver values to your user experience, then your users will in return validate them by authenticating their communication to you.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.