Forums

CF V3 On Submit Before Email

Nicodemus 26 Jul, 2011
I'm doing something wrong here but can't track it down.

J 1.5.23
CF

Straightforward form with checkboxes, textboxes, a textarea and an imageverification and submit button.

Sends emails ok, add rows to db table ok. Lovely.

Now I want to add some sanitisation using JRequest in the 'On Submit code - before sending email' in the 'Form Code' tab.

'compname' is a textbox in the form.

<?php
$compname = JRequest::getString('compname','Noinput','post');
JRequest::setVar('compname', $compname);
?>


I put 'Noinput' in the default value for the getString in the hope it would show up in the email and table row thus indicating the code was running but I get nothing 😟 Nor does CF's debug show 'Noinput' in the POST array for 'compname'.

Emails are on in the general tab. DB Connection is enabled and set to 'after email'. Mootools upgrade plugin is disabled. J email cloaking plugin is ordered before the chronoforms J plugin.

There is a thank you message in the 'On Submit code - after sending email'

The form is embedded in an article using the CF J plugin.

Nick
GreyHead 26 Jul, 2011
Hi Nicodemus ,

All that sounds correct to me. Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
Nicodemus 26 Jul, 2011
Will do, thanks Bob.

Nick
GreyHead 26 Jul, 2011
Hi Nick,

I can't see why this isn't working - but it isn't. Maybe something in Joomla! changed ???

Here's a workaround:
<?php
$compname = JRequest::getString('compname', 'Noinput', 'post');
if ( !$compname ) {
  $compname = 'Noinput';
}
JRequest::setVar('compname', $compname);
?>

Bob
Nicodemus 26 Jul, 2011
Hi Bob,

Reckon you're right. Probably a change in core code somewhere. This particular site we're building doesn't have any of the more esoteric J! plugins that can sometimes cause odd behaviour like that. It's pretty bog standard with an Artisteer template, they don't often give us problems.

Thanks for the workround - I'm going to have to think carefully how I go about this since I also want to use some SSV but that's fine 🙂 .

My original purpose was to gain an indication that the JRequest was working, not to set a default. So perhaps I should dive into the core code and see what they're actually trying to filter out then see if I can inject it :mrgreen:

Again thanks for your time Bob. Much appreciated. I'll get you back when I'm not skint. I mean buy you a sherbert 🙂

Cheers
Nick
Nicodemus 27 Jul, 2011
Tested input cleansing and filtering by JRequest and tags in the J api blacklist removed 🙂

For example: <html><style='blah /><more tags> Now some text
Gets converted to: Now some text

Cheers

Nick
GreyHead 27 Jul, 2011
Hi Nick,

Good :-) Did you also get the 'default value' to work?

Bob
Nicodemus 27 Jul, 2011
Hi Bob,

Nope. Default value only works with your workround.

I'd planned to pop a question up on the J! forums but am under pressure to get this and some other stuff done sharpish. So that'll have to wait unfortunately.

Cheers
Nick
This topic is locked and no more replies can be posted.