name : contactformsave.php
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link rel="shortcut icon" href="favicon.ico"/>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Email Sending..</title>
        <link href="style.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div id="box">
            <?php
            $pass = false;
            require_once('class.phpmailer.php');
            $submit = $_POST['submit'];
            $captcha = $_POST['captcha'];
            //
//            echo $_SESSION['sCaptcha'] . '++' . $base['session']['sCaptcha'] . '--' . $captcha;
//            exit();
            if ($_SESSION['sCaptcha'] != $captcha) {
                echo 'ขออภัย คุณกรอกภาพตัวอักษร(Captcha)ไม่ถูกต้อง!!';
                echo '<br/><INPUT TYPE="BUTTON" VALUE="กลับไปแก้ไข" ONCLICK="history.go(-1)"/>';
                exit();
            }

            $title = $_POST['subject'];
            $name = $_POST['name'];
            $lastname = $_POST['lastname'];
            $mobile = $_POST['mobile'];
            $email = $_POST['email'];
            $msg = $_POST['message'];
//
            if ($submit != "") {
                if ($title != "" && $msg != "") {
                    //check gmail account
                    $gmailUsername = "map2iv@gmail.com";
                    $gmailPassword = "mapinterior";
                    $auther = "contact - web:interiorvisions.co.th";
                    $contactMail = "contact@interiorvisions.co.th";
//                $contactMail = "homelyboyz@gmail.com";
                    $contactName = "contact - web:interiorvisions.co.th";
                    //////////////////////////////////////////////////////////
                    $msg = nl2br($msg);
                    /////////////////////start send message///////////////////
                    $mail = new PHPMailer();
                    $msg = eregi_replace("<>[\]", '', $msg);
                    $mail->IsSMTP(); // telling the class to use SMTP
                    $mail->SMTPAuth = true;                  // enable SMTP authentication
                    $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
                    $mail->Host = "smtp.gmail.com";      // sets GMAIL as the SMTP server
                    $mail->Port = 465;                   // set the SMTP port for the GMAIL server
                    $mail->Username = $gmailUsername;  // GMAIL username
                    $mail->Password = $gmailPassword;            // GMAIL password
                    $mail->SetFrom($gmailUsername, $auther);  //Sender
                    $mail->Subject = $title;
                    //$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
                    $mail->MsgHTML($title . '<br/>' . $msg . '<br/>From:' . $name . $lastname . '<br/>E-mail:' . $email . '<br/>Mobile:' . $mobile);
                    $mail->AddAddress($contactMail, $contactName);
                    if (!$mail->Send()) {
                        echo $mail->ErrorInfo;
                    } else {
                        echo 'ส่ง E-mail สำเร็จแล้ว ทางเราจะทำการติดต่อกลับไปภายหลัง';
                        $pass = true;
                    }
                } else {
                    echo 'กรุณากรอกข้อมูลให้ครบทุกช่อง!!';
                }
            }
            if ($pass) {
                echo '<br/><a href="http://interiorvisions.co.th">- กลับสู่หน้าเว็บไซต์</a>';
            } else {
                echo '<br/><INPUT TYPE="BUTTON" VALUE="กลับไปแก้ไข" ONCLICK="history.go(-1)"/>';
            }
            ?>
        </div>
    </body>
</html>

© 2024 UnknownSec