· 7 years ago · Jan 03, 2019, 11:44 AM
1if(isset($_POST)) {
2// if(isset($_POST)
3 // && isset($_POST['name']) != ''
4 // && isset($_POST['tel_num']) != ''
5 // && isset($_POST['emeil']) != ''
6 // && isset($_POST['message']) != '')
7// {
8 $captcha = $_POST['g-recaptcha-response'];
9 $ip = $_SERVER['REMOTE_ADDR'];
10 $secretkey = "secret_key";
11 $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretkey."&response=".$captcha."&remoteip=".$ip);
12 $responseKeys = json_decode($response, true);
13
14 if(intval($responseKeys["success"]) !== 1) {
15 echo '<h2>Wrong captcha try again please!</h2>';
16 } else {
17 echo '<h2>Success!</h2>';
18 }
19}
20
21<form action="<?php echo $url; ?>" method="post">
22
23 <div class="contact_form intro_text <?php echo $mod_class_suffix; ?>"><?php echo $pre_text; ?></div>
24
25 <div class="contacts_form_field">
26 <label class="contacts_form_label"><?php echo JText::_('NAME_SURNAME')?>:*</label>
27 <input class="contact_form inputbox <?php echo $mod_class_suffix;?>" placeholder="<?php echo JText::_('NAME_SURNAME_PLACEHOLDER')?>" type="text" name="name" size="" value="<?php if ($err != '' && isset($_POST['name'])) { echo $_POST['name'];}?>" />
28 </div>
29
30 <div class="contacts_form_field">
31 <label class="contacts_form_label"><?php echo JText::_('CONTACTS_FORM_PHONE_LABEL')?>:</label>
32 <input class="contact_form inputbox " placeholder="<?php echo JText::_('PHONE_PLACEHOLDER')?>" type="text" name="tel_num" size="" value="">
33 </div>
34
35 <div class="contacts_form_field">
36 <label class="contacts_form_label"><?php echo $emaillabel; ?>:*</label>
37 <input class="contact_form inputbox <?php echo $mod_class_suffix;?>" placeholder="<?php echo JText::_('MAIL_PLACEHOLDER')?>" type="text" name="email" size="" value="<?php //if ($err != '' && isset($_POST['email'])) { echo $_POST['email'];}?>" />
38 </div>
39
40 <div class="contacts_form_field">
41 <label class="contacts_form_label"><?php echo $messagelabel;?>:*</label>
42 <textarea class="contact_form textarea <?php echo $mod_class_suffix;?>" placeholder="<?php echo JText::_('MESSAGE_PLACEHOLDER')?>" type="text" name="message" cols="<?php echo $messagewidth;?>" rows="4"><?php if ($err != '' && isset($_POST['message'])) { echo $_POST['message'];}?></textarea>
43 </div>
44
45 <div class="g-recaptcha" data-sitekey="6LejGoUUAAAAAJhzaiOOmnsjoERMJnXU_vJ6WHuX"></div>
46 <div class="submit-contact"><input class="button<?php echo $mod_class_suffix;?> bordered_button" type="submit" value="<?php echo JText::_('CONTACTS_FORM_BUTTON')?>" style=""/></div>
47</form>