$(".filter-off").html('');
<li><a class="ajax-form" data-form="filter/protokol.html" data-content="#protokol">Комната</a></li>
<div id="protokol"></div>
<?php
require_once("recaptchalib.php");
$pubkey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxключ";
$privkey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxключ";
$rsp = null;
/* assuming it's the first page load, when there's no $_POST */
if(!$_POST) {
$smarty->assign(
"recaptcha",
recaptcha_get_html($pubkey)
);
}
else {
if($_POST["recaptcha_response_field"] &&
$_POST["recaptcha_response_field"]!=''){
/* request validation from the reCAPTCHA API */
$rsp = recaptcha_check_answer (
$privkey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]
);
/* process form when the API has confirmed validation */
if ($rsp->is_valid) {
/* the business logic happens here ... */
/* e.g. process form, send mail, whatever */
/* return "success" in order to switch the template */
$smarty->assign(
"recaptcha",
"success"
);
}
else {
/* return an error if the CAPTCHA was incorrect */
$smarty->assign(
"recaptcha",
recaptcha_get_html($pubkey,$rsp->error)
);
}
}
else {
/* return an error if an empty CAPTCHA was submitted */
$smarty->assign(
"recaptcha",
recaptcha_get_html($pubkey,'incorrect-captcha-sol')
);
}
}
/* output to template */
$smarty->display("add.html");
?>
{if $recaptcha!="success"}
<h1>Contact Us!</h1>
<form id="contact_form" action="contact.php" method="post">
<ul id="contact">
<li class="row">
<label for="name">Name:</label>
<input type="text" id="name" name="name"
value="{$smarty.request.name}">
</li>
<li class="row">
<label for="email">E-Mail:</label>
<input type="text" id="email" name="email"
value="{$smarty.request.email}">
</li>
<li class="row">
<label for="subject">Subject:</label>
<input type="text" id="subject" name="subject"
value="{$smarty.request.subject}">
</li>
<li class="msg">
<label for="message">Message:</label>
<textarea id="message" name="message">
{$smarty.request.message}
</textarea>
</li>
<li class="row">
<label for="phone">Phone:</label>
<input type="text" id="phone" name="phone"
value="{$smarty.request.phone}">
</li>
<li class="row">
<label for="website">Website:</label>
<input type="text" id="website" name="website"
value="{$smarty.request.website}">
</li>
<li class="captcha">
<label for="recaptcha"> </label>
{nocache}{$recaptcha}{/nocache}
</li>
<li class="row">
<label for="submit"> </label>
<input type="submit" value="Send Mail">
</li>
</ul>
</form>
{else}
<h1>Thank You</h1>
<div class="success">
Your Message has been submitted successfully —<br/>
we will contact you as soon as possible.
</div>
{/if}