Letlabo Nature Reserve
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

book.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. use PHPMailer\PHPMailer\PHPMailer;
  3. use PHPMailer\PHPMailer\Exception;
  4. require 'C:\xampp\composer\vendor\phpmailer\PHPMailer\src\Exception.php';
  5. require 'C:\xampp\composer\vendor\phpmailer\PHPMailer\src\PHPMailer.php';
  6. require 'C:\xampp\composer\vendor\phpmailer\PHPMailer\src\SMTP.php';
  7. require 'C:\xampp\composer\vendor\autoload.php';
  8. if(isset($_POST['submit'])) {
  9. $name = $_POST['name'];
  10. $email = $_POST['email'];
  11. $phone = $_POST['phone'];
  12. $arrive = $_POST['arrive'];
  13. $depart = $_POST['depart'];
  14. $people = $_POST['people'];
  15. $message = $_POST['message'];
  16. $mail = new PHPMailer(true);
  17. $mail->SMTPDebug = 2; // Enable debugging
  18. $mail->isSMTP();
  19. $mail->Host = 'smtp.gmail.com';
  20. $mail->SMTPAuth = true;
  21. $mail->Username = 'infoletlabo@gmail.com';
  22. $mail->Password = 'Garfield@13';
  23. $mail->SMTPSecure = 'tls'; // Enable SSL secure email
  24. $mail->Port = 587; // Port no may change
  25. //Recipients
  26. $mail->setFrom($email, $name); // User email
  27. $mail->addAddress('infoletlabo@gmail.com', 'Letlabo Nature Reserve'); // Your email
  28. $mail->addcc ($email);
  29. $mail->addReplyTo($email, $name); // Replay to User
  30. //Content
  31. $mail->isHTML(false);
  32. $mail->Subject = 'Accommodation Request';
  33. $mail->Body = 'Equiry From: '.$name."\r\n".'Booking Dates: ' ."\r\n". 'Start Date: '.$arrive."\r\n".'End Date: '.$depart."\r\n".'Email: '.$email."\r\n".'Phone: '.$phone."\r\n".'Number of People:'.$people."\r\n".'Comments: : '.$message;
  34. if($mail->send()) {
  35. echo "<script type='text/javascript'>alert('submitted successfully!')</script>";
  36. }
  37. else
  38. {
  39. echo "<script type='text/javascript'>alert('failed!')</script>";
  40. }
  41. header('Location: accommodation.html');
  42. exit;
  43. }
  44. ?>