Advertisement
Guest User

TY PHP

a guest
Jul 1st, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. <?php
  2. /*
  3. Name: Thank You Form
  4. Written by: Okler Themes - (http://www.okler.net)
  5. Version: 4.4.0
  6. */
  7.  
  8. session_cache_limiter('nocache');
  9. header('Expires: ' . gmdate('r', 0));
  10.  
  11. header('Content-type: application/json');
  12.  
  13. // Step 1 - Enter your email address below.
  14. $to = 'stickykicksrc.com@gmail.com';
  15.  
  16. // Step 2 - Enable if the server requires SMTP authentication. (true/false)
  17. $enablePHPMailer = true;
  18.  
  19. // revoved html hidden value $subject = $_POST['subject'];
  20. $subject = 'Sticky Kicks RC Monthly Giveaway';
  21.  
  22. if(isset($_POST['email'])) {
  23.  
  24. $name = $_POST['name'];
  25. $email = $_POST['email'];
  26. $address = $_POST['address'];
  27. $phone = $_POST['phone'];
  28. $color = $_POST['color'];
  29. $giveaway = $_POST['giveaway'];
  30.  
  31. $fields = array(
  32. 0 => array(
  33. 'text' => 'Name',
  34. 'val' => $_POST['name']
  35. ),
  36. 1 => array(
  37. 'text' => 'Email address',
  38. 'val' => $_POST['email']
  39. ),
  40. 5 => array(
  41. 'text' => 'Color',
  42. 'val' => $_POST['color']
  43. ),
  44. 6 => array(
  45. 'text' => 'Monthly giveaway',
  46. 'val' => $_POST['giveaway']
  47. )
  48. );
  49.  
  50. $message = "";
  51.  
  52. foreach($fields as $field) {
  53. $message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "<br>\n";
  54. }
  55.  
  56. // Simple Mail
  57. if(!$enablePHPMailer) {
  58.  
  59. $headers = '';
  60. $headers .= 'From: ' . $name . ' <' . $email . '>' . "\r\n";
  61. $headers .= "Reply-To: " . $email . "\r\n";
  62. $headers .= "MIME-Version: 1.0\r\n";
  63. $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  64.  
  65. if (mail($to, $subject, $message, $headers)){
  66. $arrResult = array ('response'=>'success');
  67. } else{
  68. $arrResult = array ('response'=>'error');
  69. }
  70.  
  71. // PHP Mailer Library - Docs: https://github.com/PHPMailer/PHPMailer
  72. } else {
  73.  
  74. include("php-mailer/PHPMailerAutoload.php");
  75.  
  76. $mail = new PHPMailer;
  77.  
  78. $mail->IsSMTP(); // Set mailer to use SMTP
  79. $mail->SMTPDebug = 0; // Debug Mode
  80.  
  81. // Step 3 - If you don't receive the email, try to configure the parameters below:
  82.  
  83. $mail->Host = 'smtp.gmail.com'; // Specify main and backup server
  84. $mail->SMTPAuth = true; // Enable SMTP authentication
  85. $mail->Username = 'oklertestemail@gmail.com'; // SMTP username
  86. $mail->Password = 'Access1234!'; // SMTP password
  87. $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
  88. $mail->Port = 587; // TCP port to connect to
  89.  
  90. $mail->From = $email;
  91. $mail->FromName = $_POST['name'];
  92. $mail->AddAddress($to); // Add a recipient
  93. $mail->AddReplyTo($email, $name);
  94.  
  95. $mail->IsHTML(true); // Set email format to HTML
  96.  
  97. $mail->CharSet = 'UTF-8';
  98.  
  99. $mail->Subject = $subject;
  100. $mail->Body = $message;
  101.  
  102. if(!$mail->Send()) {
  103. $arrResult = array ('response'=>'error');
  104. }
  105.  
  106. $arrResult = array ('response'=>'success');
  107.  
  108. }
  109.  
  110. echo json_encode($arrResult);
  111.  
  112. } else {
  113.  
  114. $arrResult = array ('response'=>'error');
  115. echo json_encode($arrResult);
  116.  
  117. }
  118. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement