Hi Could it be that your message block starts with ' (single quote) so the variables are not evaluated. Variables are only evaluated when using " (double quotes) which does not mix well with HTML.
try using $message='text and HTML<tag name="zapit">'.$variable.' more text and HTML'; Peter > -----Original Message----- > From: Kevin Ruiz [mailto:[EMAIL PROTECTED]] > Sent: 15 January 2002 19:33 > To: [EMAIL PROTECTED] > Subject: [PHP-DB] passing variable through an html email > > > I'm writing a page that allows me to add users to a table. Once the users > are in the table they will be able to gain access to our > downloads section, > they will be validated against their user/pass in a mysql database. > > Here's my question. I understand how to send mail using mail(). I also > understand how to send mail in an html format which is what I'd > prefer to do > but what I'm having trouble with is passing my variables to the > email being > generated in the html format. This works fine in the plain text > emails but > can't seem to get it to work in the html emails. > > Here's my situation...once a new user is added to the database an email is > generated with their user/pass. The code I am using to send them > the email > is this: > > ================================================================ > //mails the new account holder his/her username and pass > //for testing purposes I'm sending all mail to myself > /* recipients */ > $to = "Kevin Ruiz <[EMAIL PROTECTED]>"; > > /* subject */ > $subject = "Access to downloads section at Worktiviti.com"; > > /* message */ > $message = ' > > <html> > <head> > <title>Access to downloads section at Worktiviti.com</title> > <style> > p{font-family:arial; font-size:8pt;} > </style> > </head> > <body> > <table width="100%" border=0 cellspacing=2 cellpadding=0> > <tr> > <td valign=top><img > src="http://www.worktiviti.com/images/gifs/logo.gif" > alt="worktiviti"></td> > </tr> > </table> > <table width="100%" border=0 cellspacing=2 cellpadding=0> > <tr> > <td> > > <p> > Dear $real_name ,<br /><br /> > An account has been created for you to access the downloads > section of the Worktiviti website.<br /><br /> > You can log into your account <a > href=http://www.worktiviti.com/protected/login.php>here</a>.<br /><br /> > Your username and password are as follows:<br /> > Username: $username<br /> > Password: $password<br /><br /> > If you have any problems loggin into your account or have any > questions please contact the <a > href=mailto:[EMAIL PROTECTED]>webmaster</a>. > </p> > </td> > </tr> > </table> > > </body> > </html> > '; > > /* To send HTML mail, you can set the Content-type header. */ > $headers = "MIME-Version: 1.0\r\n"; > $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; > > /* additional headers */ > $headers .= "From: Do Not Reply<[EMAIL PROTECTED]>\r\n"; > > /* and now mail it */ > mail($to, $subject, $message, $headers); > > ======================================================================== > If you sent the code now it would send fine except the variables > $real_name, > $username, & $password would not echo anything. They would simply print > themselves. I've tried a number of variations. Some of which include > \"$real_name\", "$real_name", '$real_name',<?= $real_name ?>. > Nothing seems > to work. I'm editing the page in dreamweaver. As soon as I try > to put the > "<? ?>" into the code to tell it that some php is coming it tells > me I have > an error. > > Does anyone have any idea what I'm doing wrong? > > Any help woudl be greatly appreciated. > > Thanks, > Kevin > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]