Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $JustPHP = true;
- require_once '../start.php';
- require_once '../PHPMailer-master/PHPMailerAutoload.php';
- if(isset($_POST['name']) && isset($_POST['message']) && isset($_POST['subject']) && isset($_POST['email'])) {
- $_SESSION['got_here'] = 'First';
- /*$curl = curl_init();
- curl_setopt_array($curl, [
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_URL => 'https://www.google.com/recaptcha/api/siteverify',
- CURLOPT_POSTFIELDS => [
- 'secret' => '6LdLJCMTAAAAAKRMXIU4qElgBERe-dh9WqxrWb56',
- 'response' => $_POST['g-recaptcha-response'],
- ],
- ]);
- $response = json_decode(curl_exec($curl));*/
- //if($response->success) {
- $data = array('name' => $_POST['name'],
- 'email' => $_POST['email'],
- 'matter' => $_POST['matter'],
- 'subject' => $_POST['subject'],
- 'message' => $_POST['message'],
- 'date' => $CurrentDate,
- );
- if($db->insert('contact_sent', $data)) {
- $_SESSION['got_here'] = 'Second';
- foreach ($_POST as $key => $value) {
- if($key != "g-recaptcha-response") {
- if(isset($_SESSION[$key])) {
- unset($_SESSION[$key]);
- }
- $mail = new PHPMailer;
- $mail->isSMTP();
- $mail->Host = 'send.one.com';
- $mail->SMTPAuth = true;
- $mail->Username = 'albert@mollernielsen.dk';
- $mail->Password = 'lolnope';
- $mail->SMTPSecure = 'ssl';
- $mail->Port = 465;
- $mail->setFrom('albert@mollernielsen.dk', $_POST['name']);
- $mail->addAddress('albert@mollernielsen.dk', 'Albert Møller Nielsen');
- $mail->addReplyTo($_POST['email'], $_POST['name']);
- $mail->isHTML(true);
- $mail->Subject = 'Contact Form: ' . $_POST['subject'];
- $mail->Body = $_POST['message'];
- if(!$mail->send()) {
- $error = 'Mail not sent: ' . $mail->ErrorInfo;
- } else {
- $_SESSION['got_here'] = 'Third';
- }
- }
- }
- $success = true;
- } else {
- $error = 'Error inserting';
- }
- /*} else {
- $error = 'reCAPTCHA';
- }*/
- } else {
- $error = 'Required posts is not sat';
- }
- if(isset($error)) $_SESSION['error'] = $error;
- if(isset($error)) echo $error;
- if(isset($success)) {
- if($success) echo 'Succcess';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement