Guest User

Untitled

a guest
Apr 24th, 2019
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST) & !empty($_POST))
  4. {
  5.  
  6.  
  7. $name = htmlspecialchars(stripslashes($_POST['name']));
  8. $email = htmlspecialchars(stripslashes($_POST['email']));
  9. $number = htmlspecialchars(stripslashes(trim($_POST['number'])));
  10. $cmessage = htmlspecialchars(stripslashes($_POST['message']));
  11.  
  12. if($name != "" || !empty($name) && $email != "" || !empty($email) && $number != "" || !empty($number) && $cmessage != "" || !empty($cmessage))
  13. {
  14. if(!preg_match("/^[A-Za-z .]+$/", $name) || !preg_match("/^[A-Za-z .]+$/", $name))
  15. {
  16. $name_error = 'Invalid Name';
  17. ?>
  18. <script>window.location="contact-us?error=name</script>
  19. <?php
  20. }
  21.  
  22. if(!preg_match("/^[0-9]+$/", $number))
  23. {
  24. $number_error = 'Invalid Phone No.';
  25. ?>
  26. <script>window.location="contact-us?error=number</script>
  27. <?php
  28. }
  29. if(strlen($cmessage) === 0)
  30. {
  31. $message_error = 'Your message should not be empty';
  32. ?>
  33. <script>window.location="contact-us?error=message</script>
  34. <?php
  35. }
  36.  
  37.  
  38.  
  39.  
  40. require("class.phpmailer.php");
  41. require("class.smtp.php");
  42.  
  43. $mail = new PHPMailer();
  44. // $mail->IsSMTP();
  45. // $mail->SMTPDebug = 2;
  46. $mail->Host = "mail.drsanjaybansal.com";
  47. $mail->SMTPAuth = true;
  48. // $mail->SMTPSecure = "ssl";
  49. $mail->Port = 587;
  50. $mail->Username = "info@drsanjaybansal.com";
  51. $mail->Password = "^$z1#1Iw~Ki.";
  52.  
  53. $mail->From = "info@drsanjaybansal.com";
  54. $mail->FromName = "Contact Form";
  55. $mail->AddAddress("drsanjaybansal1979@gmail.com");
  56. $mail->AddAddress("bansal_sanjay79@yahoo.com");
  57. $mail->AddAddress("aparajita@drsanjaybansal.com");
  58.  
  59. $mail->AddAddress("ramavtar.stintlief@gmail.com");
  60.  
  61.  
  62.  
  63. $mail->IsHTML(true);
  64. $mail->Subject = "Contact Query Form";
  65. $mail->Body = '<!DOCTYPE html>
  66. <html>
  67. <head>
  68. <title>Contact Query Form</title>
  69. </head>
  70.  
  71. <body>
  72. <div style="width: 1000px;height: auto; background-color: #f6f6f6;">
  73.  
  74. <br>
  75. <center><img src="http://drsanjaybansal.com/images/logo.png" alt="company logo" style="width:300px;height:150px">
  76. <h1><strong>Contact Query Form</strong></h1>
  77. <hr style="width: 600px;">
  78. </center>
  79. <br>
  80. <center><h2><strong><u>Details</u></strong></h2></center>
  81. <br>
  82. <table style="border: 2px solid;padding: 2%;margin: auto;overflow-x:auto;width:99%"> <tr>
  83. <td><div>
  84.  
  85.  
  86. <div>&nbsp;</div>
  87. <div><b>Name : '.$name.'</b></div>
  88. <div>&nbsp;</div>
  89. <div><b>Phone Number : '.$number.'</b></div>
  90. <div>&nbsp;</div>
  91. <div><b>Email id : '.$email.'</b></div>
  92. <div>&nbsp;</div>
  93. <div><b>Message : '.$cmessage.'</b></div>
  94. <div>&nbsp;</div>
  95.  
  96.  
  97.  
  98.  
  99.  
  100. </div></td>
  101. </tr>
  102. </table>';
  103.  
  104.  
  105. if($mail->Send())
  106. {
  107.  
  108. ?>
  109. <script>
  110. alert('Thanks For Contacting Us!!We will get back to you shortly');
  111. window.location="index.php";
  112.  
  113. </script>
  114.  
  115.  
  116. <?php
  117.  
  118.  
  119. }
  120. else
  121. {
  122. ?>
  123. <script>
  124. alert('Ooops Something went wrong.Please try again or Call on the number Given');
  125. window.location="index.php";
  126.  
  127. </script>
  128.  
  129.  
  130. <?php
  131.  
  132. }
  133.  
  134. }
  135.  
  136. }
  137.  
  138. ?>
Add Comment
Please, Sign In to add comment