Advertisement
ferdhika31

Mailer

Jun 14th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.43 KB | None | 0 0
  1. <?php
  2. //If the form is submitted
  3. if(isset($_POST['submit'])) {
  4.  
  5.         //Check to make sure that the name field is not empty
  6.         if(trim($_POST['contactname']) == '') {
  7.                 $hasError = true;
  8.         } else {
  9.                 $name = trim($_POST['contactname']);
  10.         }
  11.  
  12.         //Check to make sure that the subject field is not empty
  13.         if(trim($_POST['subject']) == '') {
  14.                 $hasError = true;
  15.         } else {
  16.                 $subject = trim($_POST['subject']);
  17.         }
  18.  
  19.         //Check to make sure sure that a valid email address is submitted
  20.         if(trim($_POST['email']) == '')  {
  21.                 $hasError = true;
  22.         } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
  23.                 $hasError = true;
  24.         } else {
  25.                 $email = trim($_POST['email']);
  26.         }
  27.  
  28.         //Check to make sure comments were entered
  29.         if(trim($_POST['message']) == '') {
  30.                 $hasError = true;
  31.         } else {
  32.                 if(function_exists('stripslashes')) {
  33.                         $comments = stripslashes(trim($_POST['message']));
  34.                 } else {
  35.                         $comments = trim($_POST['message']);
  36.                 }
  37.         }
  38.  
  39.         //If there is no error, send the email
  40.         if(!isset($hasError)) {
  41.                 $emailTo = 'alkesprodisalkes@yahoo.com'; //Put your own email address here
  42.                 $body = "Name: $name \n\nEmail: $email \n\nAlamat: $subject \n\nPertanyaan:\n $comments";
  43.                 $headers = 'From: '.$name.'<'.$email.'>' . "\r\n" . 'Reply-To: ' . $email;
  44.                 $subjecto= 'Pertanyaan Tentang Aplikasi Registrasi Online';
  45.  
  46.                 mail($emailTo, $subjecto, $body, $headers);
  47.                 $emailSent = true;
  48.         }
  49. }
  50. ?>
  51. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  52.         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  53. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  54.  
  55. <head>
  56.         <title>Pertanyaan</title>
  57.         <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  58.         <meta http-equiv="Content-Style-Type" content="text/css" />
  59.  
  60. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
  61. <script src="jquery.validate.pack.js" type="text/javascript"></script>
  62.  
  63. <script type="text/javascript">
  64. $(document).ready(function(){
  65.         $("#contactform").validate();
  66. });
  67. </script>
  68.  
  69. <style type="text/css">
  70. body {
  71.         font-family:Arial, Tahoma, sans-serif;
  72. }
  73. #contact-wrapper {
  74.         width:430px;
  75.         border:1px solid #e2e2e2;
  76.         background:#f1f1f1;
  77.         padding:20px;
  78. }
  79. #contact-wrapper div {
  80.         clear:both;
  81.         margin:1em 0;
  82. }
  83. #contact-wrapper label {
  84.         display:block;
  85.         float:none;
  86.         font-size:16px;
  87.         width:auto;
  88. }
  89. form#contactform input {
  90.         border-color:#B7B7B7 #E8E8E8 #E8E8E8 #B7B7B7;
  91.         border-style:solid;
  92.         border-width:1px;
  93.         padding:5px;
  94.         font-size:16px;
  95.         color:#333;
  96. }
  97. form#contactform textarea {
  98.         font-family:Arial, Tahoma, Helvetica, sans-serif;
  99.         font-size:100%;
  100.         padding:0.6em 0.5em 0.7em;
  101.         border-color:#B7B7B7 #E8E8E8 #E8E8E8 #B7B7B7;
  102.         border-style:solid;
  103.         border-width:1px;
  104. }
  105. .style1 {font-size: 18px}
  106. </style>
  107. </head>
  108.  
  109. <body>
  110.  
  111. <div>
  112.   <p align="left"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="style1">&nbsp;&nbsp;&nbsp;TANYA JAWAB TENTANG PENGUNAAN </span></strong></p>
  113.   <p align="left" class="style1"><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;APLIKASI REGISTRASI  PRODIS ALKES </strong></p>
  114. </div>
  115.         <div id="contact-wrapper">
  116.  
  117.         <?php if(isset($hasError)) { //If errors are found ?>
  118.                 <p class="error">Mohon isi field dengan benar. terima kasih.</p>
  119.         <?php } ?>
  120.  
  121.         <?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
  122.                 <p><strong>Pertanyaan Sudah Terkirim!</strong></p>
  123.                 <p>Terima kasih <strong><?php echo $name;?> </strong>. Pertanyaan anda akan segera kami balas melalui email.</p>
  124.         <?php } ?>
  125.  
  126.         <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform">
  127.                 <div>
  128.                     <label for="name"><strong>Name:</strong></label>
  129.                         <input type="text" size="50" name="contactname" id="contactname" value="" class="required" />
  130.                 </div>
  131.  
  132.                 <div>
  133.                         <label for="email"><strong>Email:</strong></label>
  134.                         <input type="text" size="50" name="email" id="email" value="" class="required email" />
  135.                 </div>
  136.  
  137.                 <!--<div>
  138.                         <label for="subject"><strong>Alamat:</strong></label>
  139.                         <input type="text" size="50" name="subject" id="subject" value="" class="required" />
  140.                 </div>-->
  141.  
  142.                 <div>
  143.                         <label for="message"><strong>Pertanyaan:</strong></label>
  144.                         <textarea rows="5" cols="50" name="message" id="message" class="required"></textarea>
  145.                 </div>
  146.             <input type="submit" value="Kirim" name="submit" />
  147.         </form>
  148.         </div>
  149. </body>
  150. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement