Advertisement
Guest User

Contact Form

a guest
Mar 28th, 2015
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.30 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  
  5. Template name: Contact page
  6.  
  7. */
  8.  
  9. get_header();
  10.  
  11. the_post();
  12.  
  13. global $zorkis_options;
  14.  
  15. if(isset($_POST['postComment']) ) {
  16.  
  17.     if( !$_POST['zork_name'] || !$_POST['zork_email'] || !$_POST['zork_message'] || $_POST['zork_name'] == '' ||
  18.  
  19.         $_POST['zork_email'] == ''  || $_POST['zork_message'] == '' ) {
  20.  
  21.         $error = 'Please fill in all the required fields';
  22.  
  23.     }
  24.  
  25.     else
  26.  
  27.     {
  28.  
  29.         //everything's fine, we continue with sending the e-mail
  30.  
  31.         $name = esc_html($_POST['zork_name']);
  32.  
  33.         $email = esc_html($_POST['zork_email']);
  34.  
  35.         $message = esc_html($_POST['zork_message']);
  36.  
  37.         $msg = 'Name: ' . $name . PHP_EOL;
  38.  
  39.         $msg .= 'E-mail: ' . $email . PHP_EOL;
  40.  
  41.         $msg .= 'Message: ' . $message;
  42.  
  43.         $to = $zorkis_options['email'];
  44.  
  45.         $sitename = get_bloginfo('name');
  46.  
  47.         $subject = '[' . $sitename . ']' . ' New Message';
  48.  
  49.         $headers = 'From: ' . $name . ' <' . $email . '>' . PHP_EOL;
  50.  
  51.         wp_mail($to, $subject, $msg, $headers);
  52.  
  53.         $ok = "Message succesfully sent";
  54.  
  55.     }
  56.  
  57. }
  58.  
  59. ?>
  60.  
  61. <div id="main">
  62.  
  63.     <div class='container'>
  64.  
  65.         <div class='row'>
  66.  
  67.             <div class='content span8 blog-page'>
  68.  
  69.             <?php if ( function_exists('yoast_breadcrumb') ) {
  70.  
  71. yoast_breadcrumb('<p id="breadcrumbs">','</p>');
  72.  
  73. } ?>
  74.  
  75.                 <article>
  76.  
  77.                     <h1 class='title'><?php the_title();?></h1>
  78.  
  79.                     <div class='blog-content'>
  80.  
  81.                         <?php the_content();?>
  82.  
  83.                         <div class="clear"></div>
  84.  
  85.                         <div class="contact-form">
  86.  
  87.                             <?php if(isset($error) && $error != '') { ?>
  88.  
  89.                                 <div class="alert alert-error">
  90.  
  91.                                     <div class="inner-alert">
  92.  
  93.                                         <?php echo $error;?>
  94.  
  95.                                     </div>
  96.  
  97.                                 </div>
  98.  
  99.                             <?php } ?>
  100.  
  101.  
  102.  
  103.                             <?php if(isset($ok ) && $ok != '') { ?>
  104.  
  105.                                 <div class="alert alert-success">
  106.  
  107.                                     <div class="inner-alert">
  108.  
  109.                                         <?php echo $ok;?>
  110.  
  111.                                     </div>
  112.  
  113.                                 </div>
  114.  
  115.                             <?php } ?>
  116.  
  117.  
  118.  
  119.                             <form id="commentform" class="contactform" method="post" action="<?php echo(get_permalink($post->ID)); ?>">
  120.  
  121.                                 <input id="name" type="text" name='zork_name' placeholder="<?php _e('Your name ...', 'zorkis');?>" class='span5 contact-input'/>
  122.  
  123.                                 <input id="email" type="email" name='zork_email' placeholder="<?php _e('Your email ...', 'zorkis');?> " class='span5 contact-input' />
  124.  
  125.                                 <textarea id="message" name="zork_message" rows="10" class='span7 contact-input' placeholder="<?php _e('Your message ...', 'zorkis');?>"></textarea>
  126.  
  127.                                 <input id="send_message" type="submit" name="postComment" value='<?php _e('Send Message', 'zorkis');?>' class='btn btn-custom btn-red btn-medium btn-large-text' />
  128.  
  129.                             </form>
  130.  
  131.                         </div>
  132.  
  133.                     </div>
  134.  
  135.  
  136.  
  137.                 </article>
  138.  
  139.             </div>
  140.  
  141.         </div>
  142.  
  143.     </div>
  144.  
  145. </div>
  146.  
  147. <?php get_footer();?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement