Advertisement
BackuPs-nl

rttheme 11 contacform fix for godaddy

Mar 1st, 2016
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.22 KB | None | 0 0
  1. <?php
  2. $your_email=trim($_POST['your_email']);
  3. $your_web_site_name=trim($_POST['your_web_site_name']);
  4. ?>
  5.  
  6. <?php
  7. //If the form is submitted
  8. if(isset($_POST['name'])) {
  9.  
  10.         //Check to make sure that the name field is not empty
  11.         if(trim($_POST['name']) === '') {
  12.             $hasError = true;
  13.         } else {
  14.             $name = trim($_POST['name']);
  15.         }
  16.        
  17.         //Check to make sure sure that a valid email address is submitted
  18.         if(trim($_POST['email']) === '')  {
  19.             $hasError = true;
  20.         } else if (!preg_match('^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$^', trim($_POST['email']))) {
  21.             $hasError = true;
  22.             $errorMessage = $_POST['text_4'];
  23.         } else {
  24.             $email = trim($_POST['email']);
  25.         }
  26.  
  27.         //phone
  28.         if(isset($_POST['phone'])) $phone = trim($_POST['phone']);
  29.        
  30.         //company name
  31.         if(isset($_POST['company_name'])) $company_name = trim($_POST['company_name']);
  32.  
  33.         //company url
  34.         if(isset($_POST['company_url'])) $company_url = trim($_POST['company_url']);       
  35.            
  36.         //Check to make sure comments were entered 
  37.         if(trim($_POST['message']) === '') {
  38.             $hasError = true;
  39.         } else {
  40.             if(function_exists('stripslashes')) {
  41.                 $comments = stripslashes(trim($_POST['message']));
  42.             } else {
  43.                 $comments = trim($_POST['message']);
  44.             }
  45.         }
  46.  
  47.         //If there is no error, send the email
  48.         if(!isset($hasError)) {
  49.  
  50.             $emailTo = $your_email;
  51.             $subject = 'Contact Form Submission from '.$name;
  52.            
  53.             //message body
  54.             $body  ="Name: $name \n\n";
  55.             $body .="Email: $email \n\n";
  56.             if(isset($phone)) $body .="Phone:$phone\n\n";
  57.             if(isset($company_name)) $body .="Company Name: $company_name\n\n";
  58.             if(isset($company_url)) $body .="Company Url: $company_url \n\n";
  59.             $body .="Message: $comments";
  60.  
  61.             $headers = 'From '.$your_web_site_name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To ' . $email;
  62.            
  63.             mail($emailTo, $subject, $body, $headers);
  64.             $emailSent = true;
  65.         }
  66. }
  67. ?>
  68.  
  69. <?php if(isset($emailSent) == true) { ?>
  70.     <div class="ok_box">
  71.         <h3><?php echo $_POST['text_1'];?>, <?php echo $name;?></h3>
  72.         <p><?php echo $_POST['text_2'];?></p>
  73.     </div>
  74. <?php } ?>
  75.  
  76. <?php if(isset($hasError) ) { ?>
  77.     <div class="error_box">
  78.         <?php echo $_POST['text_3'];?>
  79.         <br />
  80.         <?php echo @$errorMessage;?>
  81.     </div>
  82. <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement