How To Make PHP Contact Form In Wordpress(Wordpress trick)

We can easily put contact form in wordpress using plugins. But plugins make your wordpress site loading slow and can lead to vulnerable .Its easy to make a custom PHP contact form. It is also very helpful on skill of 

PHP learning. And I am using PHP contact form in my wordpress Blog :)







You have 2 files, 1 HTML file and 1 PHP file

First you will have to upload a PHP file In your web hosting.Here is the PHP file




<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name n Message: $message";
$recipient = "Your Target Email Address";
$subject = "Contact Form";
$mailheader = "From: $email rn";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
 
 Open a notepad and save the code as mail.php
If you dont have a notepad download it From Here Its very useful software for programming learning
After that upload the mail.php file to your webhosting at public_html folder where you installed your wordpress
Then you will find a link like this http://www.yourwebsite.com/mail.php
Now Click on Add A Page . Give title "Contact Us" of the page and Paste the following HTML code

 
<form action="http://www.yourwebsite.com/mail.php" method="POST">
<p>Name</p> <input type="text" name="name">
<p>Email</p> <input type="text" name="email">
<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />
<input type="submit" value="Send"><input type="reset" value="Clear">


You only have to change the red colored text in the code. After that publish your contact form page.You are done
It will be difficult for newbies so comment here if getting problem
As we need your help so share our writings or website. Thank you
Share this article :
 

Post a Comment

 

Copyright © 2011. Tricks Duniya - All Rights Reserved