2

I tried to use the method from this question, but it didn't work for me. I always get this error after submiting form:

Fatal error: Cannot use object of type JInput as array in contact.php line 76...

Line 76 looks like this:

$res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']);

My contact form:

<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>

I added this to 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>');
}
Community
  • 1
  • 1
Frostbourn
  • 330
  • 3
  • 21

1 Answers1

0

Instead of

JFactory::getApplication()->input->post;

Try

JRequest::get('post');