Ciao a tutti, in un modulo peronalizzato di prenotazioni online vorrei mettere la funzionalità Captcha, che conosco bene in un form php, ma che in drupal non funziona. Il codice, inserito un un hook form, è questo:
<?php
if (isset($_SESSION['captchaText'])) {
$captchaText = $_SESSION['captchaText'];
$path_captcha = drupal_get_path("module", "prenota") . "/captcha.php?captchaText=" . $_SESSION['captchaText'];
unset($_SESSION['captchaText']);
} else {
$captchaText = substr(md5(uniqid('')),-5,5);
$_SESSION['captchaText'] = $captchaText;
$path_captcha = drupal_get_path("module", "prenota") . "/captcha.php?captchaText=" . $captchaText;
}
$form['info_privacy_fileds']['txt_captcha'] = array(
'#type' => 'item',
'#title' => t('Inserisci il codice antispam-antihacker'),
'#description' => t('Questa e una protezione Antispam/Antihacker'),
'#maxlength' => 6,
'#size' => 18,
'#value' => '',
'#required' => TRUE,
'#prefix' => '<div>',
'#suffix' => '<img src="'.$path_captcha.'" alt="Protezione per convalidare i campi del modulo prima di inviare e-mail" name="captcha" width="233" height="49" id="captcha" /></div>',
'#attributes' => array('id' => 'txt_captcha'),
);
$form['info_privacy_fileds']['txt_captcha_hidden'] = array('#type' => 'hidden', '#size' => 18, '#value' => $captchaText);
$form['info_privacy_fileds']['txt_captcha_insert'] = array(
'#type' => 'textfield',
'#size' => 18,
'#maxlength' => 5,
'#default_value' => variable_get('txt_captcha_insert', ''),
);
?>
Il codice, inserito un un hook validate, è questo:
<?php
if (empty($form_state['values']['txt_captcha_insert'])) {
form_set_error('txt_captcha_insert', t('Completare il codice di sicurezza! Nota: non fa differenza tra maiuscole minuscole'));
}
if (!empty($form_state['values']['txt_captcha_insert'])) {