Loading

Simple PHP contact form That Works !!




It was always a Challenge on the web for me in my initial days of web development to find a “Working” PHP contact form, Sometimes if its working its difficult to customize, Some looks good but does not work.

With this article  you can either directly Paste the HTML code in your Contact page ( with a HTML editor) and use it.
Files required

1. contact.html
2. contact.php
3. thankyou.html

Steps

include the source code of the <form> </form> part in your custom designed contact form or use the contact.htm

upload the contact.php file to the same level of the contact.htm in your FTP

Configure the contact.php with the destination email address, Contact form subject and From ( NOTE: the from address should be a email adress @ the domain name of the site itself)

upload a thankyou.html that will be the redirection page to show thankyou for contacting us message

How it works

- please carefully read through the variables used in the contact form HTML
- The entered data is transfered into variables and transfered to the php form that will have a function that sends the email with the variables in the body

So make sure you dont change any variable fields unless you know what you are doing.
Also if you want to add an extra field or remove a filed, make sure that you add or remove the corresponding variable as well

I hope i was able to make it simple if you have any questions, please add a comment , i would be happy to help.

contact.php is given below

<?php
$file=”thankyou.htm”;
if(isset($_POST['submit'])) {
$from = “admin@domainname.com“;
$to = “personalid@gmail.com“;
$subject = “Orangecopper.com  form”;
$name1_field = $_POST['firstname'];
$name2_field = $_POST['lastname'];
$email_field = $_POST['email'];
$job_field = $_POST['jobtitle'];
$company_field = $_POST['company'];
$phone_field = $_POST['phone'];
$country_field = $_POST['country'];
$function_field = $_POST['function'];
$nature_field = $_POST['nature'];
$message = $_POST['message'];
$contact_field = $_POST['contactback'];
$body = “From: $name1_field\n Email: $email_field\n Job Title: $job_field\n Phone: $phone_field\n Country: $country_field\n Function: $function_field\n NatureOfBiz: $nature_field\n Message:\n $message\n Contact back: $contact_field”;
 
include(“$file”);
mail($to, $subject, $body,”From:”.$from);
} else {
echo “ERROR!!, please re check and resubmit”;
}
?>

1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.75 out of 5)
Loading ... Loading ...

You might want to read these as well

Loading...







Simple PHP contact form That Works !!

Joshu is the Founder of the OrangeCopper Webmaster's Community, He had been designing & developing web applications as a freelancer in this field for the past 9 years. OC was born in 2002 December and since 2004 Joshu had been Blogging on the Web about what he learned the Hard way, So that you could learn it the Easy Way. Follow OrangeCopper on Twitter and you would be Auto-Followed.


blog comments powered by Disqus