Sending HTML with variables!

A

Anonymous

Guest
Hello People

Currently I am practising with a PHP Comment Form. So people can send an email to the webmaster. What the plan is is that the user receives a confirmation that his email has been sent. And second, the webmaster will get an email. Now, I want to get these emails in HTML format.

I figured out how to activate HTML emails without using PEAR. But when I start using variables in this email the email plain copies the variables as they are: "$first_name $last_name wrote this comment: $comment".

So, no comments, no names, no nothing.

I have the code, but the variables are mostly in dutch. Hopefully you can see past 'em.

Code:
if (empty($errors)) {
		
		$body = "Bedankt voor je commentaar. Er wordt zo spoedig mogelijk contact met je opgenomen.";
		$email = $_POST['email'];
		$extra = "From: $email";
		$voornaam = $_POST['voornaam'];
		$achternaam = $_POST['achternaam'];
		$comment = $_POST['commentaar'];
		$message = '
		<html><head><title>Commentaar van $voornaam</title></head>
		<body>
		<p><b>$voornaam $achternaam</b> heeft het volgende over je website gezegd:<br />
		<i>$comment</i></body></html>';
		/* To send HTML mail, set the Content-type header. */ 
		$headers  = "MIME-Version: 1.0\n"; 
		$headers .= "Content-type: text/html; charset=iso-8859-1\n"; 

		/* Additional headers */ 
		$headers .= "From: $email\n";
		$titel = "Commentaar van $voornaam";
		
		mail ($email, 'A Title For the mail', $body, 'From: info@myvisions.nl');
		mail ('info@myvisions.nl', $titel, $message, $headers);
		
		echo '<p>Your comment has been sent!</p>';

I translated some...
Thanks for reading.

Maarten
 
Make it like this (example):
Code:
<?php

$message = '<html>
  <head>
     <title>Commentaar van ' . $voornaam . '</title>
  </head>
    <body>      
    <p>
    <b>' . $voornaam . ' ' . $achternaam . '</b> heeft het volgende over je website gezegd:
    <br />
    <i>' . $comment . '</i>
  </body>
</html>';

?>
Get it ?
 
Back
Top