Need PHP Variable to be added to Subject in HTML EMAIL

This should be simple for a PHP Expert. I need to have the PHP Variable $BuyerSpecialist  added to the email subject when the form is sent.

This is what I currently have but I was just guessing. The only thing that comes through is the Showing Request -
$Subject = "Showing Request - " .$BuyerSpecialist ."" ;

Link to webpage
http://bit.ly/9S2a3h

Below is the php code
<?php
$recipients = array(

'recipient_1' => 'blah@blahblah, blah@blahblah',
'recipient_2' => 'blah@blahblah, blah@blahblah',

);


// get posted data into local variables
$EmailFrom = "helen@helenoliveri.com";
$EmailTo = $recipients[$_REQUEST['recipient']];
$Subject = "Showing Request - " .$BuyerSpecialist ."" ;
$BuyerSpecialist = Trim(stripslashes($_POST['BuyerSpecialist'])); 
$Date = Trim(stripslashes($_POST['Date'])); 
$TimeFrame = Trim(stripslashes($_POST['TimeFrame'])); 
$Number = Trim(stripslashes($_POST['Number'])); 

$row=<<<ROW

	<tr style='margin-top:.5em; '><td colspan='4'><font size='+1'><b>Showing TOKEN1</b></font></td></tr>
	<tr><td><font size='+1'><b>Address</b></font></td> <td><font size='+1'><b>City</b></font></td> <td><font size='+1'><b>MLS#</b></font></td> <td><font size='+1'><b>Time</b></font></td></tr>
	<tr><td><font size='+1'>TOKEN2</font></td> <td><font size='+1'>TOKEN3</font></td> <td><font size='+1'>TOKEN4</font></td> <td><font size='+1'>TOKEN5</font></td></tr>

ROW;

$msg="";
foreach($_POST['Address'] as $k=>$v)
{
	$tmp=$row;
	$tmp=str_replace('TOKEN1', (1 + (int)$k), $tmp);
	$tmp=str_replace('TOKEN2', !empty($_POST['Address'][$k]) ? stripslashes(trim($_POST['Address'][$k])) : "&nbsp;",$tmp);	
	$tmp=str_replace('TOKEN3', !empty($_POST['City'][$k]) ? stripslashes(trim($_POST['City'][$k])) : "&nbsp;",$tmp);	
	$tmp=str_replace('TOKEN4', !empty($_POST['MLS'][$k]) ? stripslashes(trim($_POST['MLS'][$k])) : "&nbsp;",$tmp);	
	$tmp=str_replace('TOKEN5', !empty($_POST['Time'][$k]) ? stripslashes(trim($_POST['Time'][$k])) : "&nbsp;",$tmp);
	$msg.=$tmp;
}


// Comments

$Notes = Trim(stripslashes($_POST['Notes'])); 




// validation
$validationOK=true;
if (Trim($BuyerSpecialist)=="") $validationOK=false;
if (Trim($Date)=="") $validationOK=false;
if (Trim($TimeFrame)=="") $validationOK=false;
if (Trim($Number)=="") $validationOK=false;
/*
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.helenoliveri.com/pages/showing.html\">";
  exit;
}
*/

// prepare email body text
$Body = "";
$Body .= "<font size='+1'>BuyerSpecialist: </font>";
$Body .= "<font size='+1'>". $BuyerSpecialist ."</font>";
$Body .= "<br>";
$Body .= "<br>";
$Body .= "<font size='+1'>Date: </font>";
$Body .= "<font size='+1'>".$Date ."</font>";
$Body .= "<br>";
$Body .= "<br>";
$Body .= "<font size='+1'>TimeFrame: </font>";
$Body .= "<font size='+1'>".$TimeFrame ."</font>";
$Body .= "<br>";
$Body .= "<br>";
$Body .= "<font size='+1'>Number: </font>";
$Body .= "<font size='+1'>".$Number ."</font>";
$Body .= "<br>";
$Body .= "<br>";
$Body .= "<table border='1' cellpadding='1'>" .$msg . "</table>";
$Body .= "<br>";
$Body .= "<font size='+1'>Notes: </font>";
$Body .= "<font size='+1'>".$Notes ."</font>";
$Body .= "<br>";


$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: <$EmailFrom>\r\n";
//echo $Body;exit;


// send email 
$success = mail($EmailTo, $Subject, $Body, $headers);

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.helenoliveri.com/pages/showing.html\">";
}
else{
  print "error";
}
?>

Open in new window

shawnzerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hawardenCommented:
Try: $Subject = "Showing Request - $BuyerSpecialist" ;

Your syntax was for function calls.
0
thedwillCommented:
$Subject = "Showing Request - " .$BuyerSpecialist ;


too many quotes!  . concats your quoted text with you variable, so the above should yield:

Showing Request - VALUE of Buyer Specialist

0
hieloCommented:
>>This is what I currently have but I was just guessing.
>>$Subject = "Showing Request - " .$BuyerSpecialist ."" ;
You guessed CORRECTLY!!! BUT you need to set the value of $Subject AFTER you have set the value of $BuyerSpecialist. In other words, swap the order of lines 13 and 14:
...
// get posted data into local variables
$EmailFrom = "helen@helenoliveri.com";
$EmailTo = $recipients[$_REQUEST['recipient']];
$BuyerSpecialist = Trim(stripslashes($_POST['BuyerSpecialist'])); 
$Subject = "Showing Request - " .$BuyerSpecialist;
$Date = Trim(stripslashes($_POST['Date'])); 
$TimeFrame = Trim(stripslashes($_POST['TimeFrame'])); 
$Number = Trim(stripslashes($_POST['Number'])); 

...

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

shawnzerAuthor Commented:
Try: $Subject = "Showing Request - $BuyerSpecialist" ;

Did not work but $BuyerSpecialist did not show in the subject line either just the

Showing Request -
0
hawardenCommented:
Shawzer, as hielo pointed out, you are assigning the value to $BuyerSpecialist ~after~ trying to use it in $Subject, so naturally there is nothing in it. You need to assign the value first, and then use it in $Subject:

$BuyerSpecialist = Trim(stripslashes($_POST['BuyerSpecialist']));
$Subject = "Showing Request - $BuyerSpecialist" ;
0
shawnzerAuthor Commented:
Thanks again hielo !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.