Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I use a $_SESSION[Firstname]  variable in the $mail->Body part of the email

Posted on 2014-03-23
13
Medium Priority
?
359 Views
Last Modified: 2014-03-23
I'm using a php script to send an email with a html body. In the body I would like to use SESSION variables to form part of the body.
Here is the body code:
$mail->Body    = '<h1>Extra Leverage</h1> Your application to become a Member has been accepted.<p>Welcome.';
I tried the following but it doesn't show up in the email body:
$mail->Body    = '<h1>Extra Leverage</h1> <?php echo $_SESSION[Firstname]<br />; ?>
Your application to become a Member has been accepted.<p>Welcome.';
0
Comment
Question by:dynorich
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
13 Comments
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39949117
Use $_SESSION['Firstname']: don't forget quotes.
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39949119
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 39949120
Try this.
$mail->Body    = '<h1>Extra Leverage</h1> ' . $_SESSION['Firstname'] . '<br />
Your application to become a Member has been accepted.<p>Welcome.'; 

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:dynorich
ID: 39949128
I tried:
$mail->Body    = '<h1>Extreme Leverage</h1> <?php echo $_SESSION['Firstname']; ?><br/>Your application to become a Member has been accepted.<p>Welcome.';
and got error:
Parse error: syntax error, unexpected T_STRING in /home3/dynorich/public_html/extraleverage/noc/purchase_member.php on line 234
0
 

Author Closing Comment

by:dynorich
ID: 39949136
Thank you. It worked perfectly!
0
 

Author Comment

by:dynorich
ID: 39949145
When I tried to add another variable, I got this error
$mail->Body    = '<h1>Extra Leverage</h1> ' . $_SESSION['Firstname'] . S_SESSION['cid']'<br />
Your application to become a Member has been accepted.<p>Welcome.';

Parse error: syntax error, unexpected '[' in /home3/dynorich/public_html/extraleverage/noc/purchase_member.php on line 234
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39949146
You forgot  a dot:

$mail->Body    = '<h1>Extra Leverage</h1> ' . $_SESSION['Firstname'] . S_SESSION['cid'] . '<br />
Your application to become a Member has been accepted.<p>Welcome.';
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39949148
Keep in mind you didn't leave any blank space between the two variables so if the first name is Marco and the cid i 123 you'll get Marco123.
0
 

Author Comment

by:dynorich
ID: 39949156
Still got same error
0
 

Author Comment

by:dynorich
ID: 39949159
should I post this as a new question so you get the points?
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39949169
As you wish... but have you still the error?
0
 

Author Comment

by:dynorich
ID: 39949174
No. It's working now.
Thanks very much
0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39949178
:)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question