Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <link rel="stylesheet" type="text/css" href="buttons.css">
  5. <link rel="stylesheet" type="text/css" href="table.css">
  6. <script type="text/javascript">
  7.  
  8. function toggle_visibility(id){
  9. var e = document.getElementById(id);
  10.  
  11. if(e.style.visibility == 'hidden'){
  12. e.style.visibility = 'visible';
  13. }
  14. else{
  15. e.style.visibility = 'hidden';
  16. }
  17.  
  18. }
  19.  
  20. function sendTicket() {
  21. var httpRequest2;
  22. //alert("hi there");
  23.  
  24. if (window.XMLHttpRequest) { // Mozilla, Safari, ...
  25. httpRequest2 = new XMLHttpRequest();
  26. if (httpRequest2.overrideMimeType) {
  27. httpRequest2.overrideMimeType('text/xml');
  28. }
  29. }
  30. else if (window.ActiveXObject) { // IE
  31. try {
  32. httpRequest2 = new ActiveXObject("Msxml2.XMLHTTP");
  33. }
  34. catch (e) {
  35. try {
  36. httpRequest2 = new ActiveXObject("Microsoft.XMLHTTP");
  37. }
  38. catch (e) {}
  39. }
  40. }
  41. if (!httpRequest2) {
  42. alert('Giving up :( Cannot create an XMLHTTP instance');
  43. return false;
  44. }
  45. httpRequest.open('GET', 'send_mail.php', true);
  46.  
  47. httpRequest.onreadystatechange = function() {
  48. sendEmail(httpRequest2);
  49. }
  50. httpRequest2.send();
  51. }
  52. function sendEmail(httpRequest){
  53. if (httpRequest.readyState == 4) {
  54. if (httpRequest.status == 200){
  55. var status = JSON.parse(httpRequest.responseText);
  56. console.log(status);
  57. }
  58. }
  59. }
  60.  
  61.  
  62.  
  63. </script>
  64. </head>
  65. <body>
  66. <h1>Welcome! </h1>
  67. <div id="buttons">
  68. <button class="myButton" onclick="processData()">View My Tickets</button>
  69. <button class="myButton" onclick="toggle_visibility('Submit');">Submit Ticket</button>
  70. <button class="myButton">Change my Password</button>
  71. </div>
  72. <div id = "table" > </div>
  73. <div id = "Submit" style="visibility: hidden;">
  74. <form action="send_mail.php" method="post">
  75. First Name:
  76. <input type="text" name="firstName">
  77. <br> Last Name:
  78. <input type="text" name="lastName">
  79. <br> Email:
  80. <input type="text" name="email">
  81. <br>
  82. <br> Problem Subject:
  83. <input type="text" name="subject">
  84. <br>
  85. <br> Problem Description: <br/>
  86. <textarea name="msg" rows="5" cols="60"></textarea>
  87. <br>
  88. <input type="submit" onclick="sendTicket();">
  89. </form>
  90. </div>
  91. </body>
  92. </html>
  93.  
  94. <?php
  95. include("config.php");
  96. include("TicketClass.php");
  97.  
  98. $mailpath = '/Applications/XAMPP/xamppfiles/PHPMailer';
  99. $path = get_include_path();
  100. set_include_path($path . PATH_SEPARATOR . $mailpath);
  101. require 'PHPMailerAutoload.php';
  102. $mail = new PHPMailer();
  103.  
  104. $mail->IsSMTP(); // telling the class to use SMTP
  105. $mail->SMTPAuth = true; // enable SMTP authentication
  106. $mail->SMTPSecure = "tls"; // sets tls authentication
  107. $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server; or your email service
  108. $mail->Port = 587; // set the SMTP port for GMAIL server; or your email server port
  109.  
  110. $mail->Username = "----"; // email username
  111. $mail->Password = "----"; // email password
  112.  
  113.  
  114. $subj = strip_tags($_POST["subject"]);
  115. $msg = strip_tags($_POST["msg"]);
  116. $sender = strip_tags($_POST["email"]);
  117.  
  118.  
  119. $mail->addAddress('----');
  120. $mail->SetFrom($sender);
  121. $mail->Subject = "$subj";
  122. $mail->Body = "$msg";
  123.  
  124.  
  125. $mail->addAddress($sender);
  126. $mail->SetFrom("-----");
  127. $mail->Subject = "Ticket Recieved";
  128. $mail->Body = "HI WE HAVE RECIEVED YOUR TICKET REQUEST";
  129.  
  130.  
  131. if(!$mail->send()) {
  132. #echo 'Message could not be sent.';
  133. #echo 'Mailer Error: ' . $mail->ErrorInfo;
  134. }
  135. else {
  136. $Name = $_POST["firstName"] . " " . $_POST["lastName"];
  137. $ticket = new ticketClass($_POST["firstName"], $_POST["lastName"], $subj, $sender, $msg);
  138. if ($ticket->insert($conn)) {
  139. echo json_encode("Message has been sent");
  140. #echo "<form action="ticket_submit.html" method="post"> Go Back: <input type="submit"><br > </form>";
  141. $ticket->insertDes($conn);
  142. }
  143. else{
  144. echo json_encode("Failure");
  145. }
  146. }
  147.  
  148.  
  149. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement