<?php 
echo '
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<script type="text/javascript" src="'.$thisPage.'js/messages.js"></script>
<link rel="stylesheet" type="text/css" href="'.$thisPage.'css/messages.css" />
<link rel="stylesheet" type="text/css" href="'.$thisPage.'css/captcha.css" />';

$postData = $statusMsg = ''; 
$status = 'error'; 

$siteKey 	= '6LfLsq4UAAAAAJo0hnNyq5dzdpg-WAZXWpf8vQZ2';
$secretKey 	= '6LfLsq4UAAAAAGXSwWU2pAp2JqZ0Us5uMV1oz6oC'; //Your_reCAPTCHA_Secret_Key 

// If the form is submitted 
if(isset($_POST['submit'])){ 
    $postData = $_POST; 
     
    // Validate form fields 
    if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['message'])){ 
         
        // Validate reCAPTCHA box 
        if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])){ 
            // Google reCAPTCHA API secret key 
            // Verify the reCAPTCHA response 
            $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secretKey.'&response='.$_POST['g-recaptcha-response']); 
            // Decode json data 
            $responseData = json_decode($verifyResponse); 
            // If reCAPTCHA response is valid 
            if($responseData->success){ 
                // Posted form data 
                $name = !empty($_POST['name'])?$_POST['name']:''; 
                $email = !empty($_POST['email'])?$_POST['email']:''; 
                $message = !empty($_POST['message'])?$_POST['message']:''; 
                 
                // Send email notification to the site admin 
                $to = 'tradexpoindonesia@debindo.com,budiarto@debindo.com,rizal@debindo.com'; 
                $subject = 'New contact form have been submitted'; 
                $htmlContent = "
                    <h1>Contact request details</h1> 
                    <p><b>Name: </b>".$name."</p> 
                    <p><b>Email: </b>".$email."</p> 
                    <p><b>Message: </b>".$message."</p> 
                "; 
                 
                // Always set content-type when sending HTML email 
                $headers  = "MIME-Version: 1.0" . "\r\n"; 
                $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 
                // More headers chunkhu@gmail.com
                $headers .= 'From:'.$name.' <'.$email.'>' . "\r\n"; 
                $headers .= "BCc:chunkhu@gmail.com" . "\r\n";
				 
                // Send email 
                @mail($to,$subject,$htmlContent,$headers); 
                 
                $status = 'success'; 
                $statusMsg = 'Your contact request has submitted successfully.'; 
                $postData = '';
            }else{ 
                $statusMsg = 
				'Robot verification failed, please try again.'; 
            } 
        }else{ 
            $statusMsg = 'Please check on the reCAPTCHA box.'; 
        } 
    }else{ 
        $statusMsg = 'Please fill all the mandatory fields.'; 
    } 
} 
?>
<!-- Status message 
    TTrade Expo Indonesia 2019 finished on October 20, 2019 after five(5) days of great enthusiasm.
    We would like to thanks all the exhibitors participated at the show, and hope to see you again next yeat.
    <br />-->
<p>
    For any inquiries, please complete the following form:
</p>
<div class="box" style="font-size:16px; line-height:20px; ">
    <form name="form" id="form" class="form" action="" method="post">
        <?php if(!empty($statusMsg)){ ?>
            <p class="status-msg <?php echo $status; ?>"><?php echo $statusMsg; ?></p>
        <?php } ?>
        <section class="layout-centered" data-modul="M00613">
        	<div class="rowInner spacerRow">
            	<div class="teasers" style="border:1px solid #999999">
                	<div class="col l-col12 m-col12 s-col12">
                    	<div class="row" style="padding:18px 0px; background-color:#f1f1f1">
                            <div class="col l-col4 m-col12 s-col12">
                                <strong>Type You Full Name</strong>
                            </div>
                            <div class="col l-col8 m-col12 s-col12">
                                <input size="38" type="text" name="name" value="<?php echo !empty($postData['name'])?$postData['name']:''; ?>" placeholder="Your name" required="" />
                            </div>
                        </div>
                    	<div class="row" style="padding:18px 0px; background-color:#f8f8f8">
                            <div class="col l-col4 m-col12 s-col12">
                                <strong>Type Your Email Address</strong>
                            </div>
                            <div class="col l-col8 m-col12 s-col12">
                            	<input size="50" type="email" name="email" value="<?php echo !empty($postData['email'])?$postData['email']:''; ?>" placeholder="Your email address" required="" />
                            </div>
                        </div>
                    	<div class="row" style="padding:18px 0px; background-color:#f8f8f8">
                            <div class="col l-col4 m-col12 s-col12">
                            	<strong>Type Your Message</strong>
                            </div>
                            <div class="col l-col8 m-col12 s-col12">
                            	<textarea name="message" placeholder="Type message..." required="" ><?php echo !empty($postData['message'])?$postData['message']:''; ?></textarea>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <br /><br /><br />
        <table width="100%" cellpadding="18" cellspacing="1" border="0" bgcolor="#999999" style="border:1px solid #999999">
            <tr style="height:50px; background-color:#f1f1f1;">
                <td width="35%" align="right" style="background-color:#f1f1f1;">
                    <strong>Type You Full Name</strong>
                </td>
                <td style="background-color:#f1f1f1;">
                    <input size="38" type="text" name="name" value="<?php echo !empty($postData['name'])?$postData['name']:''; ?>" placeholder="Your name" required="" />
                </td>
            </tr>            
            <tr style="height:50px; background-color:#f8f8f8;">
                <td align="right" style="background-color:#f8f8f8;">
                    <strong>Type Your Email Address</strong>
                </td>
                <td style="background-color:#f8f8f8;">
                    <input size="50" type="email" name="email" value="<?php echo !empty($postData['email'])?$postData['email']:''; ?>" placeholder="Your email" required="" />
                </td>
            </tr>   
            <tr style="height:50px; background-color:#f1f1f1;">         
                <td align="right" style="background-color:#f1f1f1;">
                    Type Your Message
                </td>
                <td style="background-color:#f1f1f1;">
                    <textarea name="message" placeholder="Type message..." required="" ><?php echo !empty($postData['message'])?$postData['message']:''; ?></textarea>
                </td>
            </tr>            
            <tr style="background-color:#f8f8f8;">
                <td align="center" colspan="2" style="background-color:#f8f8f8;">
                    <div align="center" class="g-recaptcha" data-sitekey="<?php echo $siteKey; ?>"></div>
                    <div align="center" style="padding:15px">
                        <input style="height:50px; width:120px" class="hvr-sweep-to-right" type="submit" name="submit" value="SUBMIT">
                    </div>
                </td>
            </tr>            
        </table>
    </form>
</div>
    