Advertisement
Guest User

contactform.php

a guest
Sep 23rd, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 KB | None | 0 0
  1. <?php
  2.  
  3.         $errors = array();
  4.  
  5.         $name = isset($_POST['name']) ? $_POST['name'] : "";
  6.         $email = isset($_POST['email']) ? $_POST['email'] : "";
  7.         $web = isset($_POST['web']) ? $_POST['web'] : "";
  8.         $favwork = isset($_POST['favwork']) ? $_POST['favwork'] : "";
  9.         $message = isset($_POST['message']) ? $_POST['message'] : "";
  10.        
  11.         if (isset($_POST['submit']))
  12.         {
  13.                 if (empty($name)) {
  14.                         $errors['name'] = 'Please enter your name.';
  15.                 }
  16.                
  17.                 if (empty($email)) {
  18.                         $errors['email'] = 'Please enter your e-mail.';
  19.                 }
  20.                
  21.                 if (empty($web)) {
  22.                         $errors['web'] = 'Please enter your web address.';
  23.                 }
  24.                
  25.                 $to = "b.enlevygraphics@gmail.com";
  26.                 $headers = "From: " . $email;
  27.                 $subject = "Ben, you have been contacted...";
  28.                 $body = "Name: " . $name . "\nEmail: " . $email . "\nWebsite: " . $web . "\n" . "\nFavorite Piece of work: " . $favwork . "\n" . "\nMessage: " . $message;
  29.                
  30.                 if(!count($errors) && mail($to, $subject, $body, $headers)) {
  31.  
  32.                         $to = $email;
  33.                         $headers = "From: be.nlevygraphics@gmail.com" ;
  34.                         $subject = "You contacted benlevywebdesign";
  35.                         $body =  $_POST['name'].",  Thank you for taking a look at my portfolio and contacting me.  I have received your contact information/message and I will get back to you as soon as I can!" . "\n" . "\nFor your records I have:" . "\nEmail: " . $email . "\n" . "\nFavorite Piece of work: " . $favwork . "\n" . "\nMessage: " . $message;
  36.  
  37.                         if (mail($to, $subject, $body, $headers)) {
  38.                                 echo("<p class=contactformsent>".$name.", your information was received. For your records an email has also been sent to you!</p>");
  39.                         }
  40.                 }
  41.        }
  42.  
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement