Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. <?php
  2. $msg = "";
  3. use PHPMailerPHPMailerPHPMailer;
  4. include_once "PHPMailer/PHPMailer.php";
  5. include_once "PHPMailer/Exception.php";
  6. include_once "PHPMailer/SMTP.php";
  7.  
  8. if (isset($_POST['submit'])) {
  9.  
  10. //varibles from form
  11. $email = $_POST['email'];
  12. $name = $_POST['employee'];
  13. $date = $_POST['date'];
  14. $jobnum = $_POST['job#'];
  15. $radio = $_POST['radiobtn'];
  16. $customer = $_POST['customer'];
  17. $address = $_POST['location'];
  18. $jobdes = $_POST['jobdescription'];
  19. $starttime = strtotime($_POST['starttime']);
  20. $lunchtime = $_POST['lunch'];
  21. $stoptime = strtotime($_POST['stoptime']);
  22. $totalhours = $_POST['totalhours'];
  23. $drivetime = $_POST['drivetime'];
  24. $notes = $_POST['notes'];
  25. $m1 = $_POST['m-1'];
  26. $m2 = $_POST['m-2'];
  27. $m3 = $_POST['m-3'];
  28. $m4 = $_POST['m-4'];
  29. $m5 = $_POST['m-5'];
  30. $m6 = $_POST['m-6'];
  31. $m7 = $_POST['m-7'];
  32.  
  33. $q1 = $_POST['q-1'];
  34. $q2 = $_POST['q-2'];
  35. $q3 = $_POST['q-3'];
  36. $q4 = $_POST['q-4'];
  37. $q5 = $_POST['q-5'];
  38. $q6 = $_POST['q-6'];
  39. $q7 = $_POST['q-7'];
  40.  
  41. $e1 = $_POST['e-1'];
  42. $e2 = $_POST['e-2'];
  43. $e3 = $_POST['e-3'];
  44. $e4 = $_POST['e-4'];
  45. $e5 = $_POST['e-5'];
  46. $e6 = $_POST['e-6'];
  47. $e7 = $_POST['e-7'];
  48.  
  49. $t1 = $_POST['t-1'];
  50. $t2 = $_POST['t-2'];
  51. $t3 = $_POST['t-3'];
  52. $t4 = $_POST['t-4'];
  53. $t5 = $_POST['t-5'];
  54. $t6 = $_POST['t-6'];
  55. $t7 = $_POST['t-7'];
  56.  
  57. //HTML EMAIL TABLE WITH FORM DATA ENTRIES
  58. $message = "<html><body>";
  59. $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
  60. $message .= "<tr><td><strong>Tech Name:</strong> </td><td>" .$name. "</td></tr>";
  61. $message .= "<tr><td><strong>Job #:</strong> </td><td>" .$jobnum. "</td></tr>";
  62. $message .= "<tr><td><strong>Date:</strong> </td><td>" . $date . "</td></tr>";
  63. $message .= "<tr><td><strong>Start Time:</strong> </td><td>" . date('h:i a', $starttime) . "</td></tr>";
  64. $message .= "<tr><td><strong>Lunch Duration:</strong> </td><td>" . $lunchtime . "</td></tr>";
  65. $message .= "<tr><td><strong>Stop Time:</strong> </td><td>" . date('h:i a', $stoptime) . "</td></tr>";
  66. $message .= "<tr><td><strong>Total Hours:</strong> </td><td>" . $totalhours . "</td></tr>";
  67. $message .= "<tr><td><strong>Drive Time:</strong> </td><td>" . $drivetime . "</td></tr>";
  68. $message .= "<tr><td><strong>Job Complete:</strong> </td><td>" . $radio . "</td></tr>";
  69. $message .= "<tr><td><strong>Customer:</strong> </td><td>" . $customer . "</td></tr>";
  70. $message .= "<tr><td><strong>Location/Address:</strong> </td><td>" . $address . "</td></tr>";
  71. $message .= "<tr><td><strong>Job Description:</strong> </td><td>" . $jobdes . "</td></tr>";
  72. $message .= "<tr><td><strong>Notes:</strong> </td><td>" . $notes . "</td></tr>";
  73. $message .= "<tr><td><strong>FILE:</strong> </td><td>" . $file . "</td></tr>";
  74. $message .= "<tr><td><strong>Materials:</strong></td> <td><strong>Qty:</strong></td> <td><strong>Each:</strong></td> <td><strong>Total:</strong></td></tr>";
  75. $message .= "<tr><td>$m1</td><td>$q1</td><td>$e1</td><td>$t1</td>";
  76. $message .= "<tr><td>$m2</td><td>$q2</td><td>$e2</td><td>$t2</td>";
  77. $message .= "<tr><td>$m3</td><td>$q3</td><td>$e3</td><td>$t3</td>";
  78. $message .= "<tr><td>$m4</td><td>$q4</td><td>$e4</td><td>$t4</td>";
  79. $message .= "<tr><td>$m5</td><td>$q5</td><td>$e5</td><td>$t5</td>";
  80. $message .= "<tr><td>$m6</td><td>$q6</td><td>$e6</td><td>$t6</td>";
  81. $message .= "<tr><td>$m7</td><td>$q7</td><td>$e7</td><td>$t7</td>";
  82. $message .= "</table>";
  83. $message .= "</body></html>";
  84.  
  85. //SOMETHING TO DO WITH SENDING A ATTACHMENT???
  86. if (isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != "") {
  87. $file = "attachment/" . basename($_FILES['attachment']['name']);
  88. move_uploaded_file($_FILES['attachment']['tmp_name'], $file);
  89. } else
  90. $file = "";
  91.  
  92. $mail = new PHPMailer();
  93.  
  94. //set a host
  95. $mail->Host = "mail.gradyelectricforms.com";
  96.  
  97. //enable SMTP
  98. $mail->isSMTP();
  99.  
  100. //set authentication to true
  101. $mail->SMTPAuth = true;
  102.  
  103. //set login details for gmail account
  104. $mail->Username = "forms@gradyelectricforms.com";
  105. $mail->Password = "mypassword";
  106.  
  107. //set type of protection
  108. $mail->SMTPSecure = "ssl"; // or we can use TLS
  109.  
  110. //set a port
  111. $mail->Port = 465; //or 587 if TLS
  112.  
  113. $mail->setFrom($email);
  114. $mail->Subject = "NEW TIMESHEET";
  115. $mail->addAddress('example@123.com');
  116. $mail->addAddress($email);
  117. $mail->isHTML(true);
  118. $mail->Body = $message;
  119. $mail->addAttachment($file);
  120.  
  121. if ($mail->send())
  122. $msg = "Your form has been sent, thank you!";
  123. else
  124. $msg = "Please try again!";
  125.  
  126. unlink($file);
  127. }
  128. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement