Forums

multiple fields displayed in Email Subject Line?

symbic 17 Jun, 2008
Hello,
I am new to Chronoforms but so far have had good success setting up a form in J1.5 capturing some basic data such as:
Name
Email Address
Selection Option
Date

(and also seem to be successful using validation)

I would like to include BOTH values Selected Option and Date in the Subject Line of the email message that is consequently emailed.

How do I do this?

Many thanks
symbic
GreyHead 17 Jun, 2008
Hi symbic,

Try this code in the 'Onsubmit before' box
<?php
$rows[0]->emailsubject = "Some text".$_POST['first_fieldname']." "$_POST['second_fieldname']." some more text";
?>
samhnky 17 Jun, 2008
GreyHead,

The code you supplied in your previous post looks like it is exactly what I need, however I can't seem to get it working. Is this something that you have used with Chronoforms, and if so is there anything else I need to do to get it working... i.e. placing a variable in the special fields subject field...

Thank you for your help,
Sam
jcksnps4 17 Jun, 2008
Is there anyway to debug this? I've tried entering my values that are being posted, but my emails are sending with blank subjects...😟
GreyHead 17 Jun, 2008
Hi jcksnps4,

Turn debug on and you'll see the values that are being returned by the form.

Add one more line to the code:
<?php
$rows[0]->emailsubject = 
  "Some text".$_POST['first_fieldname']." 
  ".$_POST['second_fieldname']." some more text"; 
if ($debug) {
  echo "subject; ";print_r($rows[0]->emailsubject);echo "<br />";
}
?>
This should print out the value of the subject as long as debug is turned on.

Bob
symbic 18 Jun, 2008
Hi GreyHead,
I've tried the code you have suggested but can't seem to get it to work correctly.

The email is sent and shows ONE of the fields in the subject line but I also end up seeing a Parse error on the resulting thankyou page

Parse error: syntax error, unexpected T_VARIABLE in
/home/account/public_html/subdomain/components
/com_chronocontact/chronocontact.php(425)
: eval()'d code on line 2
E-mail: 'Yes' custom
Email sent





(If the Subject Field under the Special Fields tab is left blank then it seems to default to the Email Subject shown under the General Tab, regardless of using the code above)

Thanks
Denise
GreyHead 18 Jun, 2008
Hi Denise,

Sorry there was a dot '.' missing before the second $_POST - I've put it back in my pevious post.

Bob
symbic 18 Jun, 2008
Hi greyHead,

hmmm... still getting a Parse error:

Parse error: syntax error, unexpected ':' in
/home/domain/public_html/subdomain/components/
com_chronocontact/chronocontact.php(425)
: eval()'d code on line 4
E-mail: 'Yes' custom
Email sent
E-mail message



and it shows default Email Subject

?? again if the Subject Field under the Special Fields tab is left blank then it seems to default to the Email Subject shown under the General Tab, regardless of using the code suggested.

Any further ideas??

many thanks
GreyHead 18 Jun, 2008
Hi symbic,

Not my day, there was a second typo in the next line a : instead of a ; - also fixed now.

Bob
symbic 18 Jun, 2008
Yea! Thanks very much!:cheer:

All working nicely now with both fields displayed in subject line along with set text

(Note I left Subject Field blank under the Special Fields tab)

Chronoforms has ended up providing very nice solution for what i needed.

thanks again
Denise
tonimarie 04 Jul, 2008
I was actually able to use this help to put five fields plus additional text in my subject line (a name and a date even though they were broken up into individual parts).

Thank you so much for this fix!
pdenessen 03 Dec, 2008
Hi Bob,

I have a similair Problem. I want to combine 3 fields (voornaam tussennaam naam) in the email from name of the email.

Therefore I made this code :

<?php
$rows[0]->emailnaam = $_POST['voornaam']." ".$_POST['tussennaam']." ".$_POST['naam'];
if ($debug) {
  echo "subject; ";print_r($rows[0]->emailnaam);echo "<br />";
}
?>


But I do only get the emailaddress in the from field ? (I filled emailnaam in the Dynamic Fromname field of the email setup tab.)
The output of the debug is ok.

Patrick
GreyHead 03 Dec, 2008
Hi Patrick,

Which versions of ChronoForms and Joomla are you using (apologies if we've already asked this - I don't remember)? The code here was for Joomla 1.0.x

Bob
pdenessen 03 Dec, 2008
Sorry,

I forgot to mention it🙂

Joomla 1.5.8 and Chronoforms V3.0

Patrick
Max_admin 04 Dec, 2008
Hi Patrick,

try to make it :

$emails[0]->subject = JRequest::getVar('firstname')." ".JRequest::getVar('lastname');
!replace fields names with yours!

put this cod in the onsubmit before email!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
pdenessen 04 Dec, 2008
Thanks Max,

this looks better.

I added the php tags to the code <?php and ?> at the end. But I do not want to use the "subject" field but the "Dynamic name from" field. Which variable should I use instead?

Isn't there a nice way to combine these fields in the email template fields ?


Thx

Patrick
Max_admin 04 Dec, 2008
Hi Patrick,

use dfromname instead of subject then!

nicer way? how ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
pdenessen 04 Dec, 2008
Hi Max,


either I do something wrong or it is not working😟

This is my code :
<?php
$emails[0]-> dfromname = JRequest::getVar('voornaam')." ".JRequest::getVar('tussennaam')." ".JRequest::getVar('naam');
?>


What I mean with nicer, is that you can enter multiple fields into the emailsetup tab for example dynamic fromname.
Now is only one field allowed.

best

Patrick
Max_admin 04 Dec, 2008
Hi Patrick,

Each email can have only 1 from name and 1 from email!

don't leave a space between the dfromname and the > in your code!

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jdpickering 17 Mar, 2009
I'm running Joomla 1.5.9 with ChronoForms 3.1RC2 and i'm trying to take two fields tbFirstName and tbLName and combine them to tbLName, tbFirstName and i used your example above however when I complete the form i get nothing for the From name it just gives the email address.

<?php
$emails[0]->dfromname = JRequest::getVar('tbLName').", ".JRequest::getVar('tbFirstName');
?>


Could you please tell me what is wrong with this?
GreyHead 17 Mar, 2009
Hi jdpickering,

Try without the comma - that may be being treated as a special character.

Bob
jdpickering 18 Mar, 2009
nope I even tried just this
<?php
$emails[0]->dfromname = JRequest::getVar('tbLName');
?>


and that still didn't work
jdpickering 18 Mar, 2009
I don't know if this helps at all but here is the source code to my form
<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label">First Name:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
    <input class="cf_inputbox required" id="text_10" name="tbFirstName" type="text" />
		<div class="tooltipdiv">First Name: :: Please enter your first name</div>
  </div>
  <div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label">Last Name:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
    <input class="cf_inputbox required" id="text_9" name="tbLName" type="text" />
		<div class="tooltipdiv">Last Name: :: Please enter your last name</div>
  </div>
  <div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label">Address:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
    <input class="cf_inputbox required" id="text_8" name="tbAddress" type="text" />
		<div class="tooltipdiv">Address: :: Please enter your address</div>
  </div>
  <div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label">APT/Building/Room/Suite</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
    <input class="cf_inputbox" id="text_5" name="tbAddress2" type="text" />
		<div class="tooltipdiv">APT/Building/Room/Suite :: Please enter your apt, building, room, or suite number</div>
  </div>
  <div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label">State:</label>
    <a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a>
    <br />
    <select class="cf_inputbox validate-selection" id="select_7" size="1" {cf_multiple} name="ddState">
    <option value="">Choose Option</option>
    <option value="Indiana">Indiana</option>
	<option value="Ohio">Ohio</option>
    </select>
				<div class="tooltipdiv">State: :: Please select your state.</div>
  </div>
  <div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label">Zip Code:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
    <input class="cf_inputbox required validate-number" maxlength="5" size="5" id="text_4" name="tbZip" type="text" />
    	<div class="tooltipdiv">Zip Code: :: Please enter your zip code</div>
  </div>
  <div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label">Phone Number:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
    <input class="cf_inputbox required" id="text_3" name="tbPhone" type="text" />
		<div class="tooltipdiv">Phone Number: :: Please enter your phone number.</div>
  </div>
  <div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textbox">
    <label class="cf_label">Email:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
    <input class="cf_inputbox required validate-email" id="text_2" name="tbEmail" type="text" />
		<div class="tooltipdiv">Email: :: Please enter your email address</div>
  </div>
  <div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_datetimepicker">
    <label class="cf_label">Party Date:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
    <input class="cf_datetime required" maxlength="2147483647" size="20" id="date_1" name="dtParty" type="text" />
		<div class="tooltipdiv">Party Date: :: Please choose when you would like to have your party.</div>
  </div>
  <div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_textarea">
    <label class="cf_label">Comments:</label><a class="tooltiplink" onclick="return false;"><img height="16" border="0" width="16" class="tooltipimg" src="components/com_chronocontact/css/images/tooltip.png"/></a><br />
    <textarea class="cf_inputbox" rows="5" id="text_0" cols="30" name="taComments"></textarea>
		<div class="tooltipdiv">Comments: :: Please enter any comments or questions</div>
  </div>
  <div class="clear"> </div>
</div>

<div class="form_item">
  <div class="form_element cf_button">
    <input value="Submit" type="submit" />
  </div>
  <div class="clear"> </div>
</div>
Max_admin 18 Mar, 2009
Hi jdpickering,

try to add a dynamic from name to your form and see if it comes with the email ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jdpickering 18 Mar, 2009

Hi jdpickering,

try to add a dynamic from name to your form and see if it comes with the email ?

Max



I attached a screenshot of my "Setup Email" and I have a To, Subject, Dynamic Fromname, and Dynamic FromEmail
[attachment=0]screenshot.jpg[/attachment]

Here is what I've put "On Submit Code - before sending email"
<?php
$emails[0]->dfromname = JRequest::getVar('tbLName')." ".JRequest::getVar('tbFirstName');
if ($debug) {
  echo "FromName; ";print_r(JRequest::getVar('tbLName')." ".JRequest::getVar('tbFirstName'));echo "<br />";
  echo "dfromname; ";print_r($emails[0]->dfromname);echo "<br />";
}
?>


Here is the Debug of my code and it appears its setting the right variable

_POST: Array ( [tbFirstName] => Joe [tbLName] => Pickering [tbAddress] => 123 Rainbow [tbAddress2] => [ddState] => Ohio [tbZip] => 55555 [tbPhone] => 555-555-5555 [tbEmail] => [email]test@domain.net[/email] [dtParty] => 3/13/2009 [taComments] => test [5f94541d4e96e6311c252bc917c2a875] => 1 )
FromName; Pickering Joe
dfromname; Pickering Joe
E-mail message

From: [test@domain.net]
To: [email]user@domain.com[/email]
Subject: test

First Name:
Joe
Last Name:
Pickering
Address:
123 Rainbow
APT/Building/Room/Suite

State:
Ohio
Zip Code:
55555
Phone Number:
555-555-5555
Email:
[email]test@domain.net[/email]
Party Date:
3/13/2009
Comments:
test

.
Max_admin 19 Mar, 2009
and when you test this, what do you get in the from name of the email ?

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jdpickering 20 Mar, 2009

and when you test this, what do you get in the from name of the email ?

Max


I get nothing I guess you would say I get the email address as the From name instead of saying Pickering Joe as who it is from I get [email]Test@domain.net[/email]
Max_admin 20 Mar, 2009
this is weird! can I get a temporary admin access to check that ? I have no ideas here!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
jdpickering 07 Apr, 2009
sorry I have been away for a bit. I currently am working inside XAMPP i'll get my changes uploaded and then create an account for you to take a look.
This topic is locked and no more replies can be posted.