· 5 years ago · Aug 24, 2020, 02:50 AM
1
2<?php
3
4define('TIMEZONE', 'Asia/Kuala_Lumpur');
5date_default_timezone_set(TIMEZONE);
6//use PHPMailer\PHPMailer\PHPMailer;
7
8session_start();
9 $date_val= date('Y-m-d H:i:s');
10 $myemail = 'sitiradhiahdegree97@gmail.com';
11include('index.php');
12 $Nname = filter_var($_POST["name"], FILTER_SANITIZE_STRING);
13 $Eemail = filter_var($_POST["email"], FILTER_SANITIZE_EMAIL);
14 $Ccomment = filter_var($_POST["comment"], FILTER_SANITIZE_STRING);
15
16
17// Include library file
18
19
20
21 if($_POST)
22{
23//require('constant.php');
24
25
26 //reCAPTCHA validation
27 if (empty($_POST['g-recaptcha-response'])) {
28 $captcha_error = 'Captcha is required';
29
30 }
31
32 else
33 {
34 $secret_key = '6Lfxab0ZAAAAANVNINvjNX-W0_jfgJreSO00ATfC';
35 $response = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret_key.'&response='.$_POST['g-recaptcha-response']);
36 $response_data = json_decode($response);
37 if(!$response_data->succes)
38 {
39 $captcha_error='Captcha Verification Failed';
40 }
41
42 }
43
44 //require('component/recaptcha/src/autoload.php');
45
46 //$recaptcha = new \ReCaptcha\ReCaptcha(
47 //"6Lfxab0ZAAAAANVNINvjNX-W0_jfgJreSO00ATfC");
48
49 //$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
50
51 // if (!$resp->isSuccess()) {
52 //$output = json_encode(array("Validation captcha!!!"));
53 //die($output);
54 //}
55 //}
56
57}
58include('config.php');
59
60 $sql= "INSERT INTO information(name,email,comment,date_time) VAlUES('{$Nname}','{$Eemail}','{$Ccomment}','{$date_val}')" ;
61 $query = $mysqli -> query($sql);
62 //echo"<script>confirm('Subtmitted Successfully,we will get in touch soon as possible')</script>";
63 //include('emailconfig.php')
64
65
66//include('contactus.php')
67
68
69require 'PHPMailer/src/Exception.php';
70require 'PHPMailer/src/PHPMailer.php';
71require 'PHPMailer/src/SMTP.php';
72//require_once'xampp1\htdocs\contactUS\autoloader.php';
73//use PHPMailer\PHPMailer\PHPMailer;
74
75use PHPMailer\PHPMailer\PHPMailer;
76use PHPMailer\PHPMailer\Exception;
77$mail = new PHPMailer();
78 //$mail = new PHPMailer;
79 $mail->isSMTP();
80 $mail->Host = 'smtp.gmail.com';
81 $mail->Port = 587;
82 $mail->SMTPSecure = "tls";
83 $mail->SMTPAuth = true;
84 $mail->Username = 'sitiradhiahdegree97@gmail.com';
85 $mail->Password = 'password aku';
86 $mail->setFrom('sitiradhiahdegree97@gmail.com', 'radhiah');
87 $mail->addAddress('sitiradhiahdegree97@gmail.com', 'siti radhiah');
88 $mail->addReplyTo($_POST['email'], $_POST['name']);
89 $mail->Subject = 'NEED TO REPLY';
90 $mail->isHTML(true);
91 $mail->Body = <<<EOT
92Email: $Eemail
93Name: $Nname
94Message: '$Ccomment'
95EOT;
96
97 if($mail->send())
98 {
99
100 echo"<script>alert('EMAIL SENT'),window.location.assign('../shinrai/thankyou.php'); </script>";
101
102
103 //include('index.php');
104 } else {
105 echo $mail->ErrorInfo;
106 }
107//header('Location:index.php');
108
109 if(!$query){ echo $mysqli -> error;
110 echo"<script>confirm('unsuccessful Subtmitted, Please submit again');window.location.href='index.php';</script>";
111 }
112?>