Reputation: 31
I didn't write this code, but I would like to be able to add the first name of my form to the subject line as well as a random variable. The code I got from HTML-FORM-GUIDE.com as I don't know code beyond basic html. I would also like to have a CC go to the sender. I am not sure if you needed more code than what I have pasted. I wasn't sure how to add the variables $this->first_name as well as rand(11,999) and get them to show up in the subject line.
Form area:
<label for='first_name' >First Name*: </label>
<input type='text' name='first_name' id='first_name' value='<?php echo $formproc->SafeDisplay('first_name') ?>' maxlength="60" /> <br/>
<span id='contactus_name_errorloc' class='error'></span>
PHP Code area (Goal is to have subject read as Request from First, Name & random code)
function SendFormSubmission()
{
$this->CollectConditionalReceipients();
$this->mailer->CharSet = 'utf-8';
$this->mailer->Subject = "Request from $this->name" ;
For Email the recipient code looks like this:
$formproc->AddRecipient('[email protected]');
Form field:
<label for='email' >Email*:</label></td>
<td><input type='text' name='email' id='email' value='<?php echo $formproc->SafeDisplay('email') ?>' maxlength="60" />
Upvotes: 0
Views: 432
Reputation: 1691
Please try this:
function SendFormSubmission(){
$this->CollectConditionalReceipients();
$this->mailer->CharSet = 'utf-8';
// Concat string with random number
$this->mailer->Subject = "Request from $this->name"." with random number :".rand(11,999) ;
// Add CC
$this->mailer->AddCC($senderEmail);
.
.
.
Upvotes: 1