P
P
Pavel Sidorov2021-08-17 13:30:06
1C-Bitrix
Pavel Sidorov, 2021-08-17 13:30:06

Why does captcha not pass form data?

captcha is connected in the file with the form

include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/captcha.php");
$cpt = new CCaptcha();
$captchaPass = COption::GetOptionString("main", "captcha_password", "");
if(strlen($captchaPass) <= 0)
  {
      $captchaPass = randString(10);
      COption::SetOptionString("main", "captcha_password", $captchaPass);
  }
$cpt->SetCodeCrypt($captchaPass);


There is a form with captcha. without using ajax

....
<form  action="/reviews/finish.php" enctype="multipart/form-data" accept-charset="UTF-8">
        <!--captcha_code-->
        <input name="captcha_code" value="<?=htmlspecialchars($cpt->GetCodeCrypt());?>" type="hidden">
        <input id="captcha_word" name="captcha_word" type="text">
        <img src="/bitrix/tools/captcha.php?captcha_code=<?=htmlspecialchars($cpt->GetCodeCrypt());?>">
</form>
....


form handler in another file. It has a captcha checker.

if(!$APPLICATION->CaptchaCheckCode($_POST["captcha_word"], $_POST["captcha_code"]))
  {
      // Неправильное значение
  }
  else
  {
      // Правильное значение
дальнейший код работы с формой
}


when submitting the form, captcha_code and captcha_word are gone, but the handler throws an error. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Sidorov, 2021-08-17
@pavel__sidorov

I forgot to add method="POST" in the form,
everything works

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question