Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. <?php
  2. $JustPHP = true;
  3. require_once '../start.php';
  4. require_once '../PHPMailer-master/PHPMailerAutoload.php';
  5.  
  6. if(isset($_POST['name']) && isset($_POST['message']) && isset($_POST['subject']) && isset($_POST['email'])) {
  7.  
  8. $_SESSION['got_here'] = 'First';
  9. /*$curl = curl_init();
  10. curl_setopt_array($curl, [
  11. CURLOPT_RETURNTRANSFER => 1,
  12. CURLOPT_URL => 'https://www.google.com/recaptcha/api/siteverify',
  13. CURLOPT_POSTFIELDS => [
  14. 'secret' => '6LdLJCMTAAAAAKRMXIU4qElgBERe-dh9WqxrWb56',
  15. 'response' => $_POST['g-recaptcha-response'],
  16. ],
  17. ]);
  18. $response = json_decode(curl_exec($curl));*/
  19.  
  20. //if($response->success) {
  21. $data = array('name' => $_POST['name'],
  22. 'email' => $_POST['email'],
  23. 'matter' => $_POST['matter'],
  24. 'subject' => $_POST['subject'],
  25. 'message' => $_POST['message'],
  26. 'date' => $CurrentDate,
  27. );
  28. if($db->insert('contact_sent', $data)) {
  29. $_SESSION['got_here'] = 'Second';
  30. foreach ($_POST as $key => $value) {
  31. if($key != "g-recaptcha-response") {
  32. if(isset($_SESSION[$key])) {
  33. unset($_SESSION[$key]);
  34. }
  35.  
  36. $mail = new PHPMailer;
  37. $mail->isSMTP();
  38. $mail->Host = 'send.one.com';
  39. $mail->SMTPAuth = true;
  40. $mail->Username = 'albert@mollernielsen.dk';
  41. $mail->Password = 'lolnope';
  42. $mail->SMTPSecure = 'ssl';
  43. $mail->Port = 465;
  44.  
  45. $mail->setFrom('albert@mollernielsen.dk', $_POST['name']);
  46. $mail->addAddress('albert@mollernielsen.dk', 'Albert Møller Nielsen');
  47. $mail->addReplyTo($_POST['email'], $_POST['name']);
  48. $mail->isHTML(true);
  49.  
  50. $mail->Subject = 'Contact Form: ' . $_POST['subject'];
  51. $mail->Body = $_POST['message'];
  52.  
  53. if(!$mail->send()) {
  54. $error = 'Mail not sent: ' . $mail->ErrorInfo;
  55. } else {
  56. $_SESSION['got_here'] = 'Third';
  57. }
  58.  
  59. }
  60. }
  61.  
  62. $success = true;
  63.  
  64. } else {
  65. $error = 'Error inserting';
  66. }
  67. /*} else {
  68. $error = 'reCAPTCHA';
  69. }*/
  70. } else {
  71. $error = 'Required posts is not sat';
  72. }
  73. if(isset($error)) $_SESSION['error'] = $error;
  74. if(isset($error)) echo $error;
  75. if(isset($success)) {
  76. if($success) echo 'Succcess';
  77. }
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement