Advertisement
Guest User

Untitled

a guest
Mar 9th, 2018
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. <?php
  2. use PHPMailer\PHPMailer\PHPMailer;
  3. require "PHPMailer/PHPMailer.php";
  4. require "PHPMailer/Exception.php";
  5.  
  6. if ($_SERVER['REQUEST_METHOD'] != 'POST') {
  7. header('Location: index.php');
  8. exit();
  9. }
  10.  
  11. $ch = curl_init();
  12. curl_setopt($ch, CURLOPT_URL, 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr');
  13. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  15. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  16. curl_setopt($ch, CURLOPT_POST, 1);
  17. curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&" . http_build_query($_POST));
  18. $response = curl_exec($ch);
  19. curl_close($ch);
  20.  
  21. if ($response == "VERIFIED" && $_POST['receiver_email'] == "paypalmmv@gmail.com") {
  22. $cEmail = $_POST['payer_email'];
  23. $name = $_POST['first_name'] . " " . $_POST['last_name'];
  24.  
  25. $price = $_POST['mc_gross'];
  26. $currency = $_POST['mc_currency'];
  27. $item = $_POST['item_number'];
  28. $paymentStatus = $_POST['payment_status'];
  29.  
  30.  
  31. if ($item == "NFA" && $currency == "USD" && $paymentStatus == "Completed" && $price == 1.5) {
  32. $servername = "localhost";
  33. $username = "username";
  34. $password = "password";
  35. $dbname = "myDB";
  36.  
  37. // Create connection
  38. $conn = new mysqli($servername, $username, $password, $dbname);
  39. // Check connection
  40. if ($conn->connect_error) {
  41. die("Connection failed: " . $conn->connect_error);
  42. }
  43.  
  44. $sql = "SELECT id, firstname, lastname FROM MyGuests";
  45. $result = $conn->query($sql);
  46.  
  47. if ($result->num_rows > 0) {
  48. // output data of each row
  49. while($row = $result->fetch_assoc()) {
  50. echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>"; }
  51. } else { echo "0 results"; }
  52. $conn->close();
  53.  
  54.  
  55. $mail = new PHPMailer();
  56. $mail->setFrom("admin@godalts.com", "GodAlts Order");
  57. $mail->addAddress($cEmail, $name);
  58. $mail->isHTML(true);
  59. $mail->Subject = "Purchase Details";
  60. $mail->Body = "
  61. Hi, <br><br>
  62. Thank you for purchase at GodAlts.<br><br>
  63.  
  64. Purchased Alts:
  65.  
  66.  
  67. <br><br>Kind regards,
  68. <br>GodAlts
  69. ";
  70.  
  71. $mail->send();
  72. }
  73. }
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement