mail & HTML with PHP variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vfm
Forum Commoner
Posts: 32
Joined: Tue Mar 30, 2010 10:47 pm

mail & HTML with PHP variables

Post by vfm »

Hi,

I'm really new to this and I have an HTML email which is being sent via the mail() function. However, I cant figure out how to get my php variables into the HTML.

I have a bunch of variables at the top e.g.

$sender_message=$_SESSION['sender_message'];
$photos=$_SESSION['photos'];

and then I have another variable called $msg which contains all the HTML.

What I'm trying to achieve is something like:
<tr>
<td>Your message is: </td>
<td>$sender_message</td>
</tr>
<tr>
<td>Your photos are:</td>
<td>$photos</td>
</tr>

However when I try this I get nothing. Then I thought maybe I need to break the original $msg variable into parts and insert the $sender_message separately but I still get nothing.

I hope this makes sense and would love some advice on how I can get this to work.

Thanks in advance.

Kieran.
Gargoyle
Forum Contributor
Posts: 130
Joined: Wed Jul 14, 2010 12:25 am

Re: mail & HTML with PHP variables

Post by Gargoyle »

Code: Select all

$msg = '<tr><td>Your message is: </td><td>'.$sender_message.'</td></tr><tr><td>Your photos are:</td><td>'.$photos.'</td></tr>';
vfm
Forum Commoner
Posts: 32
Joined: Tue Mar 30, 2010 10:47 pm

Re: mail & HTML with PHP variables

Post by vfm »

Hi,

THanks for the reply but that still doesn't seem to work.

I've attached a snippet of my code - just in case I'm doing something daft!!

Code: Select all

<?php
session_start();
	$sender_message=$_SESSION['sender_message'];
	$photos=$_SESSION['photos'];
		

$subject="Enquiry";


$msg .='
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<html>

<table width="100%" height="100%">
	<tbody>
	<tr>
		<td bgcolor="#e3e3e3" valign="top">
			<table border="0" cellspacing="0" cellpadding="0" width="699" bgcolor="#960407" align="center">
				<tbody>
				<tr>
					<td height="107" width="50"><img src="http://www.viewforme.com/images/spacer.gif" width="50"></td>
					<td height="107" width="599">
						<table width="599" bgcolor="#32312f" height="107">
							<tbody>
							<tr>
								<td height="107" width="350">&nbsp;&nbsp;&nbsp;&nbsp;<img style="BORDER-BOTTOM: 0px; BORDER-LEFT: 20px; WIDTH: 250px; HEIGHT: 44px; BORDER-TOP: 0px; BORDER-RIGHT: 0px" border="0" alt="View For Me logo" src="http://www.viewforme.com/images/logo.png" width="215" height="35"></td>
								<td height="107" width="249"></td>
							</tr>
							</tbody>
						</table>
					</td>
					<td height="107" width="50"><img src="http://www.viewforme.com/images/spacer.gif" width="50"></td>
				</tr>
				<tr>
					<td width="50"></td>
					<td bgcolor="#ffffff" height="27" width="599"></td>
					<td width="50"></td>
				</tr>
				<tr>
					<td width="50"></td>
					<td bgcolor="#ffffff" valign="top" width="599">
						<table>
							<tr>
								<td width="20"></td>
								<td><font color="#525252" face="Trebuchet MS"><span style="LINE-HEIGHT: 1.5; FONT-SIZE: 20px"><strong>Thankyou for submitting the property for us to view.</strong><br><br><font size="3">You supplied us with the following details:</font><br><br></td>
								<td width="20"></td>
							</tr>
							<tr>
								<td width="20"></td>
								<td><font color="#525252" face="Trebuchet MS"><strong>STEP 1 - URL:</strong></font></td>
								<td width="20"></td>
							</tr>
							<tr>
								<td width="20"></td>
								<td><font color="#909090" face="Trebuchet MS"><a href="www.blah.com">'.$sender_message.'</a></font></td>
								<td width="20"></td>
							</tr>
				
vfm
Forum Commoner
Posts: 32
Joined: Tue Mar 30, 2010 10:47 pm

Re: mail & HTML with PHP variables

Post by vfm »

Anyone??
vfm
Forum Commoner
Posts: 32
Joined: Tue Mar 30, 2010 10:47 pm

Re: mail & HTML with PHP variables

Post by vfm »

No matter all working now!
Post Reply