Advertisement
Guest User

Untitled

a guest
May 11th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.92 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include_once("config.php");
  4. include_once("includes/functions.php");
  5. require 'phpmailer/PHPMailerAutoload.php';
  6. //database configuration & connection (hiding for privacy purposes, but the database connections work fine so not relevant
  7.  
  8. if ($_POST['submit']) {
  9.  
  10. $type=$_POST['type'];
  11.  
  12. $category= substr($type, 0, strpos($type, ' -'));
  13. $category= strtolower($category);
  14. $category= ucfirst($category);
  15. $need = substr($type, strpos($type, "-") + 1);
  16.  
  17. $subject="REQUEST for " . $type;
  18. $fullname= $_SESSION['google_data']['name'];
  19. $fromemail=$_SESSION['google_data']['email'];
  20.  
  21. $brands=$_POST['brand'];
  22.  
  23. $size=$_POST['size'];
  24. if ($size == "") {
  25. $size="n/a";
  26. }
  27. $bleed=$_POST['bleed'];
  28. if ($bleed =="no") {
  29. $bleedsize="n/a";
  30. } else {
  31. $bleedsize=$_POST['bleedsize'];
  32. }
  33. $filetype=$_POST['filetype'];
  34. if ($filetype=="") {
  35. $filetype="n/a";
  36. }
  37. $footerurl=$_POST['footer-url'];
  38. if ($footerurl=="") {
  39. $footerurl="n/a";
  40. }
  41. $footerphone=$_POST['footer-phone'];
  42. if ($footerphone=="") {
  43. $footerphone="n/a";
  44. }
  45. $copy=mysqli_real_escape_string($con,$_POST['copy']);
  46. $copyforemail=$_POST['copy'];
  47.  
  48. $approved=$_POST['approved'];
  49. $seo=$_POST['seo'];
  50. $proofread=$_POST['proofread'];
  51. $info=mysqli_real_escape_string($con,$_POST['info']);
  52. $infoforemail=$_POST['info'];
  53.  
  54. $priority=$_POST['priority'];
  55. $requestdate= date('Y-m-d');
  56. $duedate = date('Y-m-d', strtotime(str_replace('-', '/', $_POST['duedate'])));
  57. if ($duedate =="1969-12-31") {
  58. $duedate="0000-00-00";
  59. }
  60. $timinginfo=mysqli_real_escape_string($con,$_POST['timinginfo']);
  61. $timinginfoforemail=$_POST['timinginfo'];
  62.  
  63. $communication=mysqli_real_escape_string($con,$_POST['communication']);
  64. $communicationforemail=$_POST['communication'];
  65.  
  66. //TEST EMAIL BEFORE INSERTING
  67. $mail = new PHPMailer;
  68. //$mail->SMTPDebug = 3; // Enable verbose debug output
  69. /*
  70. $mail->isSMTP(); // Set mailer to use SMTP
  71. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  72. $mail->SMTPAuth = true; // Enable SMTP authentication
  73. $mail->Username = ''; // SMTP username
  74. $mail->Password = ''; // SMTP password
  75. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  76. $mail->Port = 587; // TCP port to connect to
  77. */
  78. $mail->setFrom($fromemail, $fullname);
  79. $mail->addAddress('myemail@myemail.com', 'my name'); // Add recipients
  80. $mail->addReplyTo('myemail@myemail.com', 'my name');
  81. /*$mail->addCC('cc@example.com');
  82. $mail->addBCC('bcc@example.com');
  83.  
  84.  
  85. $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  86. $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name*/
  87. $mail->isHTML(true); // Set email format to HTML
  88.  
  89. $mail->Subject = "Request coming for Creative Team";
  90. $mail->Body = "Request coming";
  91. $mail->AltBody = "Request coming";
  92.  
  93. if(!$mail->send()) {
  94. echo 'Message could not be sent.';
  95. echo 'Mailer Error: ' . $mail->ErrorInfo;
  96. } else {
  97. //continue to insert
  98. }
  99.  
  100. $sql = "INSERT INTO requests (firstname, lastname, email, picture, category, type, brand, size, bleed, bleedsize, filetype, footerurl, footerphone, copy, approved, proofread, seo, info, priority, requestdate, duedate, timinginfo, communication ) VALUES ('" . $_SESSION['google_data']['given_name'] . "', '" . $_SESSION['google_data']['family_name'] . "','" . $_SESSION['google_data']['email'] . "', '" . $_SESSION['google_data']['picture'] . "', '$category', '$need', '$brands', '$size', '$bleed', '$bleedsize', '$filetype', '$footerurl', '$footerphone', '$copy', '$approved', '$proofread', '$seo', '$info', '$priority', '$requestdate', '$duedate', '$timinginfo', '$communication')";
  101.  
  102. $insertinfo = mysqli_query($con, $sql);
  103. if (!$insertinfo) {
  104. die("Database query failed: " . mysqli_error($con));
  105. } else {
  106. //Success, continue to email...
  107. }
  108.  
  109.  
  110. $plaintextversion= "
  111. $type
  112.  
  113. BRAND: $brands
  114.  
  115.  
  116. SPECS
  117.  
  118. SIZE: $size
  119.  
  120. BLEED: $bleed
  121.  
  122. BLEED SIZE: $bleedsize
  123.  
  124. FILE TYPE: $filetype
  125.  
  126. FOOTER URL: $footerurl
  127.  
  128. FOOTER PHONE: $footerphone
  129.  
  130. COPY: $copyforemail
  131.  
  132. COPY APPROVED? $approved
  133.  
  134. PROOFREAD? $proofread
  135.  
  136. ADDITIONAL INFO: $infoforemail
  137.  
  138.  
  139. TIMING
  140.  
  141. PRIORITY: $priority
  142.  
  143. REQUEST DATE: $requestdate
  144.  
  145. DESIRED DUE DATE: $duedate
  146.  
  147. TIMING INFO: $timinginfoforemail
  148.  
  149.  
  150. COMMUNICATION
  151.  
  152. ADDITIONAL PEOPLE TO INCLUDE: $communicationforemail";
  153.  
  154.  
  155. } else {
  156. header("Location:index.php");
  157. }
  158.  
  159. $mail = new PHPMailer;
  160. //$mail->SMTPDebug = 3; // Enable verbose debug output
  161. /*
  162. $mail->isSMTP(); // Set mailer to use SMTP
  163. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  164. $mail->SMTPAuth = true; // Enable SMTP authentication
  165. $mail->Username = ''; // SMTP username
  166. $mail->Password = ''; // SMTP password
  167. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  168. $mail->Port = 587; // TCP port to connect to
  169. */
  170. $mail->setFrom($fromemail, $fullname);
  171. $mail->addAddress('someone@someone.com', 'someone'); // Add recipients
  172. $mail->addReplyTo('myemail@myemail.com', 'my name');
  173. /*$mail->addCC('cc@example.com');
  174. $mail->addBCC('bcc@example.com');
  175.  
  176.  
  177. $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  178. $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name*/
  179. $mail->isHTML(false); // Set email format to plain text since that is what Salesforce needs
  180.  
  181. $mail->Subject = $subject;
  182. $mail->Body = $plaintextversion;
  183. $mail->AltBody = $plaintextversion;
  184.  
  185. if(!$mail->send()) {
  186. echo 'Message could not be sent.';
  187. echo 'Mailer Error: ' . $mail->ErrorInfo;
  188. } else {
  189. header("Location:request-success.php");
  190. }
  191. ?>
  192. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  193. <html xmlns="http://www.w3.org/1999/xhtml">
  194. <html>
  195. <head>
  196. <meta charset="utf-8">
  197. <meta name="robots" content="noindex, nofollow">
  198. <title>Untitled Document</title>
  199. </head>
  200.  
  201. <body>
  202. </body>
  203. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement