【发布时间】:2015-01-21 10:52:47
【问题描述】:
我尝试使用this question 中的方法,但它对我不起作用。 提交表单后我总是收到此错误:
致命错误:无法在 contact.php 第 76 行中使用 JInput 类型的对象作为数组...
第 76 行如下所示:
$res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']);
我的联系方式:
<div id="contact">
<div id="message"></div>
<form method="post" action="<?php
echo JURI::root() ?>modules/module/tmpl/form/contact.php" name="contactform" id="contactform">
<fieldset>
<input name="name" type="text" id="name" size="30" value="" placeholder="<?php
echo $params->get('contactname'); ?>" onfocus="this.placeholder = ''" onblur="this.placeholder = '<?php
echo $params->get('contactname'); ?>'"/>
<br />
<textarea style="width: 275px;" name="comments" cols="40" rows="3" id="comments" style="width: 350px;" placeholder="<?php
echo $params->get('contactcomment'); ?>" onfocus="this.placeholder = ''" onblur="this.placeholder = '<?php
echo $params->get('contactcomment'); ?>'"></textarea>
<br />
<br />
<?php
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onInit','recaptcha');
?>
<div id="recaptcha"></div>
<input type="submit" class="submit" id="submit" value="<?php
echo $params->get('contactbutton'); ?>" />
</fieldset>
</form>
</div>
我将此添加到contact.php
$post = JFactory::getApplication()->input->post;
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('captcha');
$res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']);
if(!$res[0]){
die('<div class="error_message">' . $errorcomments . '</div>');
}
【问题讨论】: