Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST) & !empty($_POST))
- {
- $name = htmlspecialchars(stripslashes($_POST['name']));
- $email = htmlspecialchars(stripslashes($_POST['email']));
- $number = htmlspecialchars(stripslashes(trim($_POST['number'])));
- $cmessage = htmlspecialchars(stripslashes($_POST['message']));
- if($name != "" || !empty($name) && $email != "" || !empty($email) && $number != "" || !empty($number) && $cmessage != "" || !empty($cmessage))
- {
- if(!preg_match("/^[A-Za-z .]+$/", $name) || !preg_match("/^[A-Za-z .]+$/", $name))
- {
- $name_error = 'Invalid Name';
- ?>
- <script>window.location="contact-us?error=name</script>
- <?php
- }
- if(!preg_match("/^[0-9]+$/", $number))
- {
- $number_error = 'Invalid Phone No.';
- ?>
- <script>window.location="contact-us?error=number</script>
- <?php
- }
- if(strlen($cmessage) === 0)
- {
- $message_error = 'Your message should not be empty';
- ?>
- <script>window.location="contact-us?error=message</script>
- <?php
- }
- require("class.phpmailer.php");
- require("class.smtp.php");
- $mail = new PHPMailer();
- // $mail->IsSMTP();
- // $mail->SMTPDebug = 2;
- $mail->Host = "mail.drsanjaybansal.com";
- $mail->SMTPAuth = true;
- // $mail->SMTPSecure = "ssl";
- $mail->Port = 587;
- $mail->Username = "info@drsanjaybansal.com";
- $mail->Password = "^$z1#1Iw~Ki.";
- $mail->From = "info@drsanjaybansal.com";
- $mail->FromName = "Contact Form";
- $mail->AddAddress("drsanjaybansal1979@gmail.com");
- $mail->AddAddress("bansal_sanjay79@yahoo.com");
- $mail->AddAddress("aparajita@drsanjaybansal.com");
- $mail->AddAddress("ramavtar.stintlief@gmail.com");
- $mail->IsHTML(true);
- $mail->Subject = "Contact Query Form";
- $mail->Body = '<!DOCTYPE html>
- <html>
- <head>
- <title>Contact Query Form</title>
- </head>
- <body>
- <div style="width: 1000px;height: auto; background-color: #f6f6f6;">
- <br>
- <center><img src="http://drsanjaybansal.com/images/logo.png" alt="company logo" style="width:300px;height:150px">
- <h1><strong>Contact Query Form</strong></h1>
- <hr style="width: 600px;">
- </center>
- <br>
- <center><h2><strong><u>Details</u></strong></h2></center>
- <br>
- <table style="border: 2px solid;padding: 2%;margin: auto;overflow-x:auto;width:99%"> <tr>
- <td><div>
- <div> </div>
- <div><b>Name : '.$name.'</b></div>
- <div> </div>
- <div><b>Phone Number : '.$number.'</b></div>
- <div> </div>
- <div><b>Email id : '.$email.'</b></div>
- <div> </div>
- <div><b>Message : '.$cmessage.'</b></div>
- <div> </div>
- </div></td>
- </tr>
- </table>';
- if($mail->Send())
- {
- ?>
- <script>
- alert('Thanks For Contacting Us!!We will get back to you shortly');
- window.location="index.php";
- </script>
- <?php
- }
- else
- {
- ?>
- <script>
- alert('Ooops Something went wrong.Please try again or Call on the number Given');
- window.location="index.php";
- </script>
- <?php
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment