The jquery.form library is used to send data without reloading the page, and output the result:
<script type="text/javascript"> $('document').ready(function() { $('#contact-form').ajaxForm( { target: '#preview', success: function() { $('#formbox'); } }); }); </script>
But after sending, the variable with captcha is not updated, and it turns out that when trying to send data again, it says that the captcha is not correctly entered, because its value has not been updated:
<?php include(CAPTCHA); ?> <span class="add-on"><?=$primer?></span>
Captcha is more primitive than where:
$a = rand(1,10); $b = rand(1,10); $primer = $a . '+' . $b . '= '; $_SESSION['res'] = $a + $b;
But the processing of captcha:
if (isset($_POST['captcha'])) { if ($_POST['captcha'] != $_SESSION['res']) { $msg = 'Не верно сосчитал!'; $_SESSION['mes'] = $msg; echo display_msg('Ошибка', 'alert-error', 'Не верно посчитал');; unset($_SESSION['mes']); exit; } } else { $msg = 'Капчу забыл!'; echo display_msg('Ошибка', 'alert-error', 'Капчу забыл'); exit; } unset($_SESSION['mes']);
How to update it after sending?