Hi all. Can somebody suggest a piece of code or something where the subject of the email gets changed to the name of the person who filled out the form?
ex. Let's say a guy named Jack Pearce filled in one of my forms. Then an email gets sent to me which includes the form and any attachments. Can I change the subject of the email so that every time the subject is: "Name of Company" - "Person who filled out form"? I tried while creating the email but the subject remains static. And I am not that good at HTML coding.
The name of company would remain constant.
Thanks for your help in advance.
ex. Let's say a guy named Jack Pearce filled in one of my forms. Then an email gets sent to me which includes the form and any attachments. Can I change the subject of the email so that every time the subject is: "Name of Company" - "Person who filled out form"? I tried while creating the email but the subject remains static. And I am not that good at HTML coding.
The name of company would remain constant.
Thanks for your help in advance.
Hi kingzain,
In the Email Setup use a Dynamic Subject and put subject in the box (with no quotes or brackets).
OnSubmit Before Email box add a code snippet (assuming that the name you want is in a form input called 'name'.
Bob
In the Email Setup use a Dynamic Subject and put subject in the box (with no quotes or brackets).
OnSubmit Before Email box add a code snippet (assuming that the name you want is in a form input called 'name'.
<?php
$name =& JRequest::getString('name', '', 'post');
$subject = 'Name of Company';
if ( $name ) {
$subject .= ' - '.$name;
}
JRequest::setVar('subject', $subject);
?>
Bob
I tried the snippet out but it still isn't working.
in the dynamic subject i put "HRDP - " without quotes. In the snippet box this is what i put:
<?php
$name =& JRequest::getString('First Name', '', 'post');
$subject = 'HRDP';
if ( $name ) {
$subject .= ' - '.$name;
}
JRequest::setVar('subject', $subject);
?>
The field containing the name is First name. so what went wrong?
BTW, thanks for your swift reply
in the dynamic subject i put "HRDP - " without quotes. In the snippet box this is what i put:
<?php
$name =& JRequest::getString('First Name', '', 'post');
$subject = 'HRDP';
if ( $name ) {
$subject .= ' - '.$name;
}
JRequest::setVar('subject', $subject);
?>
The field containing the name is First name. so what went wrong?
BTW, thanks for your swift reply
Hi kingzain,
I forgot to mark out the word subject - just type that in the box not HRDP
Oh, and input names can't contain spaces so 'First name' may not be the name of that input.
Bob
I forgot to mark out the word subject - just type that in the box not HRDP
and put subject in the box (with no quotes or brackets).
Oh, and input names can't contain spaces so 'First name' may not be the name of that input.
Bob
Ok I changed the subject and the form input field to 'Name'. Now i filled in a draft. In the subject I am only getting the name of company 'HRDP' and not 'HRDP - (name of person who filled form)'. Code is same as above except that I changed 'First Name' to 'Name'
Hi kingzain ,
I suspect that you are using the text from the input Label and not the name attribute of the input. Please copy and paste the Form HTML for the Name input here (or post a link to the form).
Bob
I suspect that you are using the text from the input Label and not the name attribute of the input. Please copy and paste the Form HTML for the Name input here (or post a link to the form).
Bob
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Name</label>
<input class="cf_inputbox required" maxlength="150" size="30" title="" id="text_0" name="text_0" type="text" />
</div>
<div class="cfclear"> </div>
</div>
Yeah its the label.
Hi kingzain,
Then the code becomes
Bob
Then the code becomes
<?php
$name =& JRequest::getString('text_0', '', 'post');
$subject = 'Name of Company';
if ( $name ) {
$subject .= ' - '.$name;
}
JRequest::setVar('subject', $subject);
?>
Bob
This topic is locked and no more replies can be posted.