Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="buttons.css">
- <link rel="stylesheet" type="text/css" href="table.css">
- <script type="text/javascript">
- function toggle_visibility(id){
- var e = document.getElementById(id);
- if(e.style.visibility == 'hidden'){
- e.style.visibility = 'visible';
- }
- else{
- e.style.visibility = 'hidden';
- }
- }
- function sendTicket() {
- var httpRequest2;
- //alert("hi there");
- if (window.XMLHttpRequest) { // Mozilla, Safari, ...
- httpRequest2 = new XMLHttpRequest();
- if (httpRequest2.overrideMimeType) {
- httpRequest2.overrideMimeType('text/xml');
- }
- }
- else if (window.ActiveXObject) { // IE
- try {
- httpRequest2 = new ActiveXObject("Msxml2.XMLHTTP");
- }
- catch (e) {
- try {
- httpRequest2 = new ActiveXObject("Microsoft.XMLHTTP");
- }
- catch (e) {}
- }
- }
- if (!httpRequest2) {
- alert('Giving up :( Cannot create an XMLHTTP instance');
- return false;
- }
- httpRequest.open('GET', 'send_mail.php', true);
- httpRequest.onreadystatechange = function() {
- sendEmail(httpRequest2);
- }
- httpRequest2.send();
- }
- function sendEmail(httpRequest){
- if (httpRequest.readyState == 4) {
- if (httpRequest.status == 200){
- var status = JSON.parse(httpRequest.responseText);
- console.log(status);
- }
- }
- }
- </script>
- </head>
- <body>
- <h1>Welcome! </h1>
- <div id="buttons">
- <button class="myButton" onclick="processData()">View My Tickets</button>
- <button class="myButton" onclick="toggle_visibility('Submit');">Submit Ticket</button>
- <button class="myButton">Change my Password</button>
- </div>
- <div id = "table" > </div>
- <div id = "Submit" style="visibility: hidden;">
- <form action="send_mail.php" method="post">
- First Name:
- <input type="text" name="firstName">
- <br> Last Name:
- <input type="text" name="lastName">
- <br> Email:
- <input type="text" name="email">
- <br>
- <br> Problem Subject:
- <input type="text" name="subject">
- <br>
- <br> Problem Description: <br/>
- <textarea name="msg" rows="5" cols="60"></textarea>
- <br>
- <input type="submit" onclick="sendTicket();">
- </form>
- </div>
- </body>
- </html>
- <?php
- include("config.php");
- include("TicketClass.php");
- $mailpath = '/Applications/XAMPP/xamppfiles/PHPMailer';
- $path = get_include_path();
- set_include_path($path . PATH_SEPARATOR . $mailpath);
- require 'PHPMailerAutoload.php';
- $mail = new PHPMailer();
- $mail->IsSMTP(); // telling the class to use SMTP
- $mail->SMTPAuth = true; // enable SMTP authentication
- $mail->SMTPSecure = "tls"; // sets tls authentication
- $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server; or your email service
- $mail->Port = 587; // set the SMTP port for GMAIL server; or your email server port
- $mail->Username = "----"; // email username
- $mail->Password = "----"; // email password
- $subj = strip_tags($_POST["subject"]);
- $msg = strip_tags($_POST["msg"]);
- $sender = strip_tags($_POST["email"]);
- $mail->addAddress('----');
- $mail->SetFrom($sender);
- $mail->Subject = "$subj";
- $mail->Body = "$msg";
- $mail->addAddress($sender);
- $mail->SetFrom("-----");
- $mail->Subject = "Ticket Recieved";
- $mail->Body = "HI WE HAVE RECIEVED YOUR TICKET REQUEST";
- if(!$mail->send()) {
- #echo 'Message could not be sent.';
- #echo 'Mailer Error: ' . $mail->ErrorInfo;
- }
- else {
- $Name = $_POST["firstName"] . " " . $_POST["lastName"];
- $ticket = new ticketClass($_POST["firstName"], $_POST["lastName"], $subj, $sender, $msg);
- if ($ticket->insert($conn)) {
- echo json_encode("Message has been sent");
- #echo "<form action="ticket_submit.html" method="post"> Go Back: <input type="submit"><br > </form>";
- $ticket->insertDes($conn);
- }
- else{
- echo json_encode("Failure");
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement