Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.02 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submitted'])) {
  3. if(trim($_POST['contactVorname']) === '') {
  4. $vornameError = '*';
  5. $hasError = true;
  6. } else {
  7. $vorname = trim($_POST['contactVorname']);
  8. }
  9.  
  10. if(trim($_POST['contactName']) === '') {
  11. $nameError = '*';
  12. $hasError = true;
  13. } else {
  14. $name = trim($_POST['contactName']);
  15. }
  16.  
  17. if(trim($_POST['email']) === '') {
  18. $emailError = '*';
  19. $hasError = true;
  20. } else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) {
  21. $emailError = '*';
  22. $hasError = true;
  23. } else {
  24. $email = trim($_POST['email']);
  25. }
  26.  
  27. if(trim($_POST['unternehmen']) === '') {
  28. /* $unternehmenError = '*';
  29. $hasError = true; */
  30. } else {
  31. $unternehmen = trim($_POST['unternehmen']);
  32. }
  33.  
  34. if(trim($_POST['ort']) === '') {
  35. /* $ortError = '*';
  36. $hasError = true; */
  37. } else {
  38. $ort = trim($_POST['ort']);
  39. }
  40.  
  41. if(trim($_POST['telefon']) === '') {
  42. /* $telefonError = '*';
  43. $hasError = true; */
  44. } else {
  45. $telefon = trim($_POST['telefon']);
  46. }
  47.  
  48. if(trim($_POST['betreff']) === '') {
  49. $betreffError = '*';
  50. $hasError = true;
  51. } else {
  52. $betreff = trim($_POST['betreff']);
  53. }
  54.  
  55. if(trim($_POST['comments']) === '') {
  56. $commentError = '*';
  57. $hasError = true;
  58. } else {
  59. if(function_exists('stripslashes')) {
  60. $comments = stripslashes(trim($_POST['comments']));
  61. } else {
  62. $comments = trim($_POST['comments']);
  63. }
  64. }
  65.  
  66. if(!isset($hasError)) {
  67. $emailTo = get_option('tz_email');
  68. if (!isset($emailTo) || ($emailTo == '') ){
  69. $emailTo = get_option('admin_email');
  70. }
  71. $subject = 'Kontaktformular | '.$vorname.' '.$name;
  72. $body = "\n.: Kontaktformular-E-Mail :. \n\nName: $vorname $name \nE-Mail: $email \n\nUnternehmen: $unternehmen \nOrt: $ort \nTelefon: $telefon \n\nBetreff: $betreff \n\nNachricht: $comments";
  73. $headers = 'From: '.$vorname.' '.$name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
  74.  
  75. wp_mail($emailTo, $subject, $body, $headers);
  76. $emailSent = true;
  77. }
  78.  
  79. }
  80. ?>
  81.  
  82. <?php get_header(); ?>
  83.  
  84. <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  85.  
  86. <article class="post" id="post-<?php the_ID(); ?>">
  87.  
  88. <h2 class="gross"><?php the_title(); ?></h2>
  89.  
  90. <div id="inhalt">
  91.  
  92. <div class="seitebeitrag">
  93.  
  94. <?php if(isset($emailSent) && $emailSent == true) { ?>
  95. <div><p>Vielen Dank für die Nachricht. Wir melden uns so schnell wie möglich zurück.</p></div>
  96. <?php } else { ?>
  97.  
  98. <?php the_content(); ?>
  99.  
  100. <form action="<?php the_permalink(); ?>" id="contactForm" method="post">
  101. <div id="kf0">&nbsp;</div>
  102. <div id="kf1">
  103. <p><label for="contactVorname">Vorname *</label><br />
  104. <input type="text" name="contactVorname" id="contactVorname" value="<?php if(isset($_POST['contactVorname'])) echo $_POST['contactVorname'];?>" maxlength="50" />
  105. <?php if(!empty($vornameError)) { ?>
  106. <span class="fehler"><?=$vornameError;?></span>
  107. <?php } ?></p>
  108.  
  109. <p><label for="contactName">Nachname *</label><br />
  110. <input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" maxlength="50" />
  111. <?php if(!empty($nameError)) { ?>
  112. <span class="fehler"><?=$nameError;?></span>
  113. <?php } ?></p>
  114.  
  115. <p><label for="email">E-Mail *</label><br />
  116. <input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" maxlength="50" />
  117. <?php if(!empty($emailError)) { ?>
  118. <span class="fehler"><?=$emailError;?></span>
  119. <?php } ?></p>
  120.  
  121. <p><label for="unternehmen">Unternehmen</label><br />
  122. <input type="text" name="unternehmen" id="unternehmen" value="" maxlength="50" /></p>
  123.  
  124. <p><label for="ort">Ort</label><br />
  125. <input type="text" name="ort" id="ort" value="" maxlength="50" /></p>
  126.  
  127. <p><label for="telefon">Telefon</label><br />
  128. <input type="text" name="telefon" id="telefon" value="" maxlength="50" /></p>
  129. </div>
  130.  
  131. <div id="kf2">
  132. <p><label for="betreff">Betreff *</label><br />
  133. <input type="text" name="betreff" id="betreff" value="<?php if(isset($_POST['betreff'])) echo $_POST['betreff'];?>" maxlength="50" />
  134. <?php if(!empty($betreffError)) { ?>
  135. <span class="fehler"><?=$betreffError;?></span>
  136. <?php } ?></p>
  137.  
  138. <p><label for="commentsText">Nachricht *</label><br />
  139. <textarea name="comments" id="commentsText" rows="20" cols="30"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea>
  140. <?php if(!empty($commentError)) { ?>
  141. <span class="fehler"><?=$commentError;?></span>
  142. <?php } ?></p>
  143. <p>* Pflichtfelder</p>
  144. </div>
  145.  
  146. <div id="kf3">
  147. <input type="submit" value="SENDEN" alt="senden" class="btn" /><br /><input type="hidden" name="submitted" id="submitted" value="true" />
  148. </div>
  149.  
  150. <div id="kf4">
  151. <?php if(isset($hasError) || isset($captchaError)) { ?>
  152. <div><p class="error fehler">* ungültige oder fehlende Daten</p></div>
  153. <?php } ?></div>
  154.  
  155. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement