Hi, is there a way how to add a variable into the e-mail, e.g. I have a select form:
I hope, you understand,
thank you, Jan
<select name="sel">
<option value="0" selected="selected">- Select -</option>
<option value="1">Great</option>
<option value="2">Good</option>
</select>Then I can get and change the code which will be displayed as confirmation (On Submit code - before sending email)if (isset($_POST['sel'])) {
if ($_POST['sel'] == 1) {
$_POST['sel'] = 'You have selected 'Great'';
// or $sel = 'You have selected 'Great';
}
echo $_POST['sel'];
// echo $sel;
// this return: You have selected 'Great'...BUT if I add the {sel} code into the e-mail template, I get only '1' not 'You have selected 'Great''
I hope, you understand,
thank you, Jan
Hi Jan,
Hmmm . . . it seems that the 'OnSubmit before' code is executed after the template is parsed (this isn't the sequence that I expected - I wonder if it has changed?)
There are at least three ways round this.
a) The simplest is to set the Select values
b)You could hack chronocontact.php and move the 'OnSubmit before' code
OR
c) Without hacking the code you could create a little substitution of your own by putting a distinctive code into the template like ##sel## and substituting this in the OnSubmit before box:
Hmmm . . . it seems that the 'OnSubmit before' code is executed after the template is parsed (this isn't the sequence that I expected - I wonder if it has changed?)
There are at least three ways round this.
a) The simplest is to set the Select values
<select name="sel">
<option value="0" selected="selected">- Select -</option>
<option value="Great">Great</option>
<option value="Good">Good</option>
</select>and put 'You have selected '{sel}'into the template.b)You could hack chronocontact.php and move the 'OnSubmit before' code
/**
* Run the On-submit 'pre e-mail' code if there is any
*/
if ( ! empty( $rows[0]->onsubmitcodeb4 ) ) {
eval( "?>" . $rows[0]->onsubmitcodeb4 );
}from around line 395 to around line 262// <-- insert here
/**
* If there are no errors and e-mail is required then build and send it.
*/all references to the Joomla 1.0.x version, Joomla 1.5 may be slightly different.OR
c) Without hacking the code you could create a little substitution of your own by putting a distinctive code into the template like ##sel## and substituting this in the OnSubmit before box:
<?php
$sel = "";
$sel_array = array(1 => "Great", 2 => 'Good');
if ( isset($_POST['sel']) ) {
$sel = "You have selected '".$sel_array[$_POST['sel']]."'";
}
$html_message = str_replace( "##sel##", $sel, $html_message );
?>Bob
The c) would be great, but:
$html_message = str_replace( "##sel##", $sel, $html_message );
doesn't work for me :-(
Jan
$html_message = str_replace( "##sel##", $sel, $html_message );
doesn't work for me :-(
Jan
Hi Jan,
Tested this time - I missed a ] in
Tested this time - I missed a ] in
$sel = "You have selected '".$sel_array[$_POST['sel']]."'"; Bob
Hi Jan,
Sorry, it works OK for me - off to lunch now. I'll post my test form when I'm back.
Bob
Sorry, it works OK for me - off to lunch now. I'll post my test form when I'm back.
Bob
Hi Jan,
Here's the code I used. Form HTML:
Here's the code I used. Form HTML:
Name: <input name="name" value="" type="text"><br />
E-mail: <input name="email" value="" type="text"><br />
<select name="sel">
<option value="0" selected="selected">- Select -</option>
<option value="1">Great</option>
<option value="2">Good</option>
</select>
<input name="submit" value="Submit" type="submit">Onsubmit before email:<?php
$sel = "";
$sel_array = array(1 => "Great", 2 => 'Good');
if ( isset($_POST['sel']) && $_POST['sel'] != '- Select -') {
$sel = "You have selected '".$sel_array[$_POST['sel']]."'";
}
$html_message = str_replace( "##sel##", $sel, $html_message );
?>Email templateSelect using bracket syntax: {sel}<br />
Select using ## syntax: ##sel##and the result isSelect using bracket syntax: 1
Select using ## syntax: You have selected 'Great'Bob [file name=test_form_14.cfbak size=2143]http://www.chronoengine.com/images/fbfiles/files/test_form_14.cfbak[/file]
thank you, the test_form 14 work for me, but in my form I still get this error:
EDIT: the problem was that I disabled the email sending for the testing the form...
it works now, thank you very much, Jan
SOLVED
Notice: Undefined variable: html_message in D:\www\J153\components\com_chronocontact\chronocontact.php(447) : eval()'d code on line 3
EDIT: the problem was that I disabled the email sending for the testing the form...
it works now, thank you very much, Jan
SOLVED
This topic is locked and no more replies can be posted.
