Guest User

Untitled

a guest
Jul 16th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.66 KB | None | 0 0
  1. <?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
  2. <?php
  3. $output = '';
  4.  
  5. $required = array('email', 'first_name', 'last_name');
  6.  
  7. $disclaimer = (' <div class="disclaimer"> If you are interested in receiving Brix updates and special offers by snail mail, please complete the following: </div> ');
  8.  
  9. $errors = array();
  10.  
  11. if (! empty($_POST)) {
  12. foreach ($required as $field) {
  13. if ( empty($_REQUEST[$field])) {
  14. $errors[$field] = 'this is required';
  15. }
  16. }
  17. if (count($errors) < 1) {
  18. // Send an email
  19. if ($_POST) {
  20. if (get_magic_quotes_gpc()) {
  21. foreach ($_POST as $key=>$value) {
  22. $temp = stripslashes($value);
  23. $_POST[$key] = $temp;
  24. }
  25. }
  26. $to = $_POST['to']; // emailsubmissions@siteowner.com
  27. $subject = $_POST['Posted From Website']."\n";
  28.  
  29. $message .= "Email: ".$_POST['email']."\n";
  30. $message .= "First Name: ".$_POST['first_name']."\n";
  31. $message .= "Last Name: ".$_POST['last_name']."\n";
  32. $message .= "Address: ".$_POST['address']."\n";
  33. $message .= "City: ".$_POST['city']."\n";
  34. $message .= "State: ".$_POST['state']."\n";
  35. $message .= "Country: ".$_POST['country']."\n";
  36. $message .= "Zip: ".$_POST['zip']."\n";
  37. $message .= "Phone Number: ".$_POST['phone_number']."\n";
  38. $message .= "Message: ".$_POST['message']."\n";
  39. $headers = "From: marypatc@turnpost.com\n"; // from address on the email to the site owner
  40. $headers .= "Content-type: text/plain; charset=UTF-8";
  41. $sent = mail($to, $subject, $message, $headers);
  42. // echo $message;
  43.  
  44. }
  45. $output .= '<p style="padding-bottom:20px;">';
  46. $output .= '<strong>Email Sent!</strong> Thank you for contacting us. Click <a style="color:#830024;" href="/index.php">Here</a> to return.';
  47. $output .= '</p>';
  48. echo $output;
  49. return;
  50.  
  51. } else {
  52. echo '<span class="error">Please fill in the following fields...</span><ul>';
  53.  
  54. foreach ($errors as $error => $value) {
  55.  
  56. echo '<li class="newerror">'.ucwords(str_replace('_',' ',$error)).' - '.$value.'</li>';
  57.  
  58. }
  59.  
  60. echo '</ul>';
  61.  
  62. }
  63. }
  64.  
  65. $output .= '<form method="post" id="contactform" name="contactform" action="'.$_SERVER['PHP_SELF'].'">';
  66. $output .= '<table class="clearfix">';
  67.  
  68.  
  69.  
  70. $fields = array( 'to'=>'dropdown', 'email'=>'text', 'first_name'=>'text', 'last_name'=>'text' );
  71.  
  72. echo $disclaimer;
  73.  
  74. $fields = array( 'address'=>'text', 'city'=>'text', 'state'=>'text', 'country'=>'text', 'zip'=>'text', 'phone_number'=>'text', 'message'=>'textarea' );
  75.  
  76.  
  77. $drops = array('Book a meeting or event'=>'hospitality@brixomaha.com', 'Stay In Touch'=>'info@brixomaha.com');
  78.  
  79. foreach ($fields as $field=>$type) {
  80.  
  81. if ($type != 'hidden') {
  82. $output .= '<tr><td><label for="'.$field.'" id="'.$field.'_label">';
  83. $output .= ucwords(str_replace('_',' ',$field));
  84.  
  85.  
  86. if (isset($errors[$field])) {
  87. $output .= ' <strong class="error"> *</strong>';
  88. }
  89.  
  90. $output .= ': </label></td>';
  91. }
  92.  
  93.  
  94. switch ($type) {
  95.  
  96. case 'textarea':
  97. $output .= '<td class="text"><textarea name="'.$field.'" id="'.$field.'" cols="30" rows="10">';
  98. if (isset($_REQUEST[$field])) {
  99. $output .= htmlspecialchars($_REQUEST[$field]);
  100. }
  101.  
  102. $output .= '</textarea></td></tr>';
  103. break;
  104.  
  105.  
  106.  
  107. case 'hidden';
  108. $output .= '<input type="hidden" name="'.$field.'" id="'.$field.'" value=""';
  109. if (isset($_REQUEST[$field])) {
  110. $output .= ' value="'.htmlspecialchars($_REQUEST[$field]).'"';
  111. }
  112.  
  113. $output .= ' />';
  114. break;
  115.  
  116.  
  117.  
  118. case 'dropdown';
  119. $output .= '<td><select name="'.$field.'" id="'.$field.'">';
  120. foreach ($drops as $option=>$address) {
  121. $output .= '<option value="'.$address.'">'.$option.'</option>';
  122. }
  123.  
  124. $output .= '</select></td></tr>';
  125. break;
  126.  
  127.  
  128.  
  129. default:
  130. $output .= '<td><input type="text" name="'.$field.'" id="'.$field.'"';
  131. if (isset($_REQUEST[$field])) {
  132. $output .= ' value="'.htmlspecialchars($_REQUEST[$field]).'"';
  133. }
  134.  
  135.  
  136. $output .= ' /></td></tr>';
  137. break;
  138.  
  139. }
  140. }
  141.  
  142. $output .= '
  143.  
  144. </table>
  145.  
  146. <input class="submit" type="submit" name="submit" value="Submit" />
  147.  
  148. </form>
  149.  
  150. ';
  151.  
  152. echo $output;
Add Comment
Please, Sign In to add comment