Forums

chronoforms On submit code not working?

newstuff 11 Nov, 2013
Revisiting one of my sites, I've been asked to remove the chronoforms anti spam validation because of accessibility requirements.

Since i have removed it, i am receiving spam. I remember that I used to manually place some code to filter and disable the submission of emails by inserting code similar to below - but it's not working, I must be doing something wrong (it's been a while now):

On Submit code - before sending email:

<?php
$ban_words = array("seo", "search engine", "abracadabra");
foreach ( $ban_words as $badword ) 
 { 
   if ( strpos($form->data['f_comments'], $badword) !== false ) 
  { 
    $mainframe->redirect('index.php');	
            }
     }
?> 


I just can't seem to crack this, as easy as it may seem!

I also tried to place the same code in Custom Server Side validation, but can't get that to work either. Is there something obvious i have missed...

Using: 4.0 RC3.4.1 31.May.2012 | Joomla 1.5
newstuff 11 Nov, 2013
thankyou so much for your quick response!

I tried that and it's still not working - it sends the form successfully. Not sure what to try next. I'm sure it's something really simple!
GreyHead 11 Nov, 2013
Hi newstuff,

In Joomla! 1.5 I think that you may need to define $mainframe:
<?php
global $mainframe;
$ban_words = array("seo", "search engine", "abracadabra");
foreach ( $ban_words as $badword ) {
    if ( strpos($form->data['f_comments'], $badword) !== false ) {
        $mainframe->redirect('index.php');
    }
}
?>

In later versions of Joomla! that becomes:
<?php
$app =& JFactory::getApplication();
$ban_words = array("seo", "search engine", "abracadabra");
foreach ( $ban_words as $badword ) {
    if ( strpos($form->data['f_comments'], $badword) !== false ) {
        $app->redirect('index.php');
    }
}
?>

Bob

PS Using !== is correct for strpos() to avoid confusion with character position 0.
newstuff 12 Nov, 2013
GreyHead to the rescue again... thankyou so much, I'll definitely try this. Appreciate your fast response and always, ever so helpful to all!
This topic is locked and no more replies can be posted.