Views: 9772
Last Modified: 11.09.2014
How Can CAPTCHA Be Displayed in an Own Component?
An example of using CAPTCHA on a page.
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Title");
?>
<?
if (isset($submit)) {
echo 'сабмит прошел...<br>';
echo $myname.'<br>';
echo $cap.'<br>';
if (!$GLOBALS["APPLICATION"]->CaptchaCheckCode($cap, $captcha_sid))
{
$error=true;
echo 'error captcha
';
}
}
?> <form id="linkForm" name="mailForm" action="test.php" method="post">
<table cellspacing="3" cellpadding="0" width="100%" bgcolor="#eeeeee" border="0">
<tbody>
<tr><td valign="top" align="right">Name *</td><td><input size="40" value="" name="myname" /></td></tr>
<tr><td valign="top" align="right">CAPTCHA *</td><td><?
$capCode = $GLOBALS["APPLICATION"]->CaptchaGetCode();
?>
<input type="hidden" name="captcha_sid" value="<?= htmlspecialchars($capCode) ?>">
<img src="/bitrix/tools/captcha.php?captcha_sid=<?= htmlspecialchars($capCode) ?>" width="180" height="40"><br>
<input size="40" value="" name="cap" /></td></tr>
<tr><td valign="top" align="right"> </td>
<td><input type="submit" value="Sent" name="submit" /> <input type="reset" value="Сбросить" name="Reset" /></td></tr>
</tbody>
</table>
</form><?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
How to Make a Component Invisible on the Home Page and Visible on Other Pages?
Solution:
if ($curPage = $APPLICATION->GetCurPage())
{
if (($curPage != "/index.php"))
{
....
}
}