Advertisement
Vita94

contactprocess.php

Apr 5th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2. include("/config.php");
  3.  
  4. if(!$_POST) exit;
  5.  
  6. $email = $_POST['Email_Address'];
  7. $error ="";
  8. $errors ="";
  9.  
  10. if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  11.     $error.="Invalid email address entered!";
  12.     $errors=1;
  13. }
  14.  
  15. if($errors==1) echo $error;
  16. else{
  17.     $values = array ('Full_Name','Email_Address','Your_Message');
  18.     $required = array('Full_Name','Email_Address','Your_Message');
  19.      
  20.  
  21.     $email_subject = "New Message From Your Social Website";
  22.     $email_content = "new message:\n";
  23.    
  24.     foreach($values as $key => $value){
  25.       if(in_array($value,$required)){
  26.         if ($key != 'subject' && $key != 'company') {
  27.           if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
  28.         }
  29.         $email_content .= $value.': '.$_POST[$value]."\n";
  30.       }
  31.     }
  32.      
  33.     if(@mail($email,$email_subject,$email_content)) {
  34.         echo 'Message sent!';
  35.     } else {
  36.         echo 'ERROR!';
  37.     }
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement