Insert database fieldata as subject trough before submit..

stefandeblock 28 Nov, 2010
Hi

When i now use my form it send nicely the form, with some fieldnames ,which is an number (ID).this corresponds with a fieldname which has a name in it. Due to some things i can't change directly the id send. Is it possible trough the before submit option to change the fieldname (which is now a number) in to the the data from another field that corresponds with the id ?
GreyHead 29 Nov, 2010
Hi stefandeblock,

Yes, you can do that in the OnSubmit Before Code box.

Bob
stefandeblock 29 Nov, 2010
Bob

can you help me on the way how it should look like? The field name in the email now is 'wedstrijd' and it gives the data from the field wedstrijd_id in the dbase. But it should give the data from the fieldname 'wedstrijdnaam'

1 beer for some good help !
GreyHead 30 Nov, 2010
Hi stefandeblock,

I'm not clear if 'westrijnaam' is in the form data or not.

If it is then you can just edit the Email template. If you need to look it up then the code would be something like this:
<?php
if ( !$mainframe->isSite() ) { return; }
$w_id = JRequest::getInt('wedstrijd', 0, 'post');
$w_naam = '';
if ( $w_id) {
   $db =& JFactory::getDBO();
 $query = "
    SELECT `wedstrijdnaam`
        FROM `#__some_table`
        WHERE `wedstrijd` = '$w_id' ;
  ";
  $db->setQuery($query);
  $w_naam = $db->loadResult();
}
JRequest:;setVar('wedstrijdnaam', $w_naam);
?>


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