Contact Form

Add a form to your site to allow your visitors to email you.

About This Script

There are two parts to this script. The form, which is what your visitors see on the page. And a PHP script which is where the message actually gets sent to you. See the instructions below for how to set this up on your site.



This part of the code goes on your web page. Place it inside the <body> tag where you would like it to appear.

<!-- Contact form provided by --> <form class="contactForm" action="submit-contact-form.php" method="post"> <label>Your name<br/> <input type="text" name="name" placeholder="Please enter your name." required="required" /></label> <label>Your email address<br/> <input type="email" name="email" placeholder="Please enter your email." required="required" /></label> <label>Subject<br/> <input type="text" name="subject" placeholder="Summary of message" required="required" /></label> <label>Message<br/> <textarea required="required" name="message" placeholder="Write your message here." rows="5" style="width:500px;"></textarea></label> <input type="submit" value="Send Message" /> </form>

This is the PHP code that runs on your server. Copy this code to a new file and name it submit-contact-form.php and save it in the same location as the page with the form from the first step. Make sure you entered your details in the boxes at the top of this page so the right code has been generated here.

<?php $sendToEmail = ""; $redirectToUrl = ""; if (!empty($_POST)) { if (!($name = filter_input(INPUT_POST, "name", FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_ENCODE_HIGH))) { die("Please enter your name"); } if (!($email = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL))) { die("Please enter a valid email address"); } if (!($subject = filter_input(INPUT_POST, "subject", FILTER_SANITIZE_STRING))) { die("Please enter a subject"); } if (!($message = filter_input(INPUT_POST, "message", FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_ENCODE_HIGH))) { die("Please enter a message"); } if (mail($sendToEmail, $subject, $message, "From: <{$email}> {$name}")) { header("Location: ". $redirectToUrl); } else { die("Message failed to send."); } }
More scripts

Do you want to expose your site to millions?
Do you want to be ranked higher in Google?
Do you want to be known as the best site in your niche?

Then look no further. Add your site in 3 simple steps. Sign up, Add your site and Start receiving votes! It only takes 10 seconds!

Sign Up to Top Site List Planet Now!

Login with one of these social networks...

Sign in with FacebookSign in with TwitterSign in with Google+Sign in with Yahoo!Sign in with LinkedIn

or create an account with your email...

Login To An Existing Account