Jump to content

"mail merge" printing using browser


kk2628

Recommended Posts

Hi,

 

I am new to this forum and not sure if this is the right place to seek solution to my problem, if not, please kindly let me know the right topic to post.

 

I have a requirement to enable user to print their particulars like name, age, etc. when they want to print out a standard invitation letter (which is a html page). They should have a choice to upload a personalinfo.csv file so that when they submit to print the page, each invitation letter can be printed with their respective personal information printed on the letter. It is like a mail merge function available in most of the word processor application, but this time is on the web.

 

I have googled and found the below which is the closest to meet the requirement but I am not still not able to make it work.

 

Source of mailMerge.php

<html>

<head>

<title>Mailing List</title>

</head>

<body>

<form>

 

 

<?

//Simple Mail merge

//presumes tab-delimmited file called maillist.dat

 

$theData = file("maillist.dat");

 

 

 

foreach($theData as $line){

$line = rtrim($line);

print "<h3>$line</h3>";

list($name, $email) = split("\t", $line);

print "Name: $name";

 

$message = <<<HERE

TO: $email:

Dear $name:

 

Thanks for being a part of the spam afficianado forum. You asked to

be notified whenever a new recipe was posted. Be sure to check our web

site for the delicious 'spam flambe with white sauce and cherries' recipe.

 

Sincerely,

 

Sam Spam,

Host of Spam Afficianados.

 

HERE;

 

 

print "<pre>$message</pre>";

 

} // end foreach

 

 

 

 

?>

</body>

</html>

 

 

 

 

Appreciate any advise.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/217358-mail-merge-printing-using-browser/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.