Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

PHP Contact Form

This simple contact form can be used to validate and send email. It checks for a few basic requirements like a properly written email address, a name and a message.

$email = trim(stripslashes($_POST[’email’]));
$email_send_to = “”;
$subject = “Enquiry From Website”;
$name = trim(stripslashes($_POST[‘name’]));
$message = trim(stripslashes($_POST[‘message’]));

if (count($_POST) >0) {
if (!filter_var($email, FILTER_VALIDATE_EMAIL) || ($name == “Your Name” || $email == “Your Email” || $message == “Message”)) {
} else {
$body = “”;
$body .= “name: “;
$body .= $name;
$body .= “\n”;
$body .= “message: “;
$body .= $message;
$body .= “\n”;

// send email
$mail_send = mail($email_send_to, $subject, $body, “From: <$email>”);

echo “Mail was successfully sent!”;
                    <form method=”post” action=”contact_form.php”>
                    <p><input name=”name” type=”text” onfocus=”if(this.value==’Your Name’) this.value=”” value=”Your Name” /></p>
                            <p><input name=”email” type=”text” onfocus=”if(this.value==’Your Email’) this.value=”” value=”Your Email” /></p>
                             <p><textarea style=”width:400px;” name=”message” onfocus=”if(this.value==’Message’) this.value=””>Message</textarea></p>
                              <p><input name=”submit” type=”submit” value=”Send Message”/></p>