Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Printing user name into my customized message body.
Old 05-11-2010, 07:50 AM Printing user name into my customized message body.
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Hi Forum,

I am generating a customized email and I want to send the user name printing in the body body of message in html...I am sending message via php mail() function.

for example:

HTML Code:
<html>
<body>
<span style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-style:normal; font-weight:normal; color:#212121; line-height:14px;">

Dear <<what variable should I use here>>,</span>

<b>Welcome to our website.</b>
</body>
</html>
Text box name of user is: ename,

This is how I am generating email.

PHP Code:
$user $_POST['ename'];
        
//$custname = $_POST['ename'];       
        //$category = $_REQUEST['category'];
        
$fromname "abcd - Team";
        
$details $_POST['char_input'];
        
$additional_parameters "-f noreply@abcd.com";
        
$toname $custname;
        
$toemail $_POST['emailaddress'];
        
//$bcc = "me@abcd.com";
        //$bcc = "";
        
$subject "$_POST['subject']";
        
$headers "MIME-Version: 1.0\r\n" "Content-type: text/html; charset=iso-8859-1\r\n" "From: Our - Team <noreply@abcd.com>" "\r\n" "Reply-To: noreply@abcd.com\r\n";
       
        
$message $details;
       
    
mail($toemail$subject$message$headers$additional_parameters); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes

Last edited by Isabella_Smith; 05-11-2010 at 07:51 AM..
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-11-2010, 09:27 AM Re: Printing user name into my customized message body.
SnapCount80's Avatar
Experienced Talker

Posts: 48
Name: Andrew
Location: Fort Wayne, IN
Trades: 0
Quote:
Originally Posted by Isabella_Smith View Post
Hi Forum,

I am generating a customized email and I want to send the user name printing in the body body of message in html...I am sending message via php mail() function.
In this case, $message is the variable that displays the content of the email body. I'm not sure what 'char_input' is sending but you can just add the name into the $message variable. It could look something like this.
PHP Code:
$custname $_POST['ename'];

$message "<html>
 <body>
 <span style='font-family:Verdana, Arial, Helvetica, sans-serif;  font-size:12px; font-style:normal; font-weight:normal; color:#212121;  line-height:14px;'>
Dear " 
$custname ",</span>
<b>Welcome to our website.</b>" 

$details 
"</body>
</html>"

__________________

Please login or register to view this content. Registration is FREE

SnapCount80 is offline
Reply With Quote
View Public Profile Visit SnapCount80's homepage!
 
Old 05-11-2010, 06:18 PM Re: Printing user name into my customized message body.
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
You can use a template system to do the job for you. ie. smarty templates
HTML Code:
<html>
<body>
<span style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-style:normal; font-weight:normal; color:#212121; line-height:14px;">

Dear {$custname},</span>

<b>Welcome to our website.</b>
</body>
</html>
PHP Code:
$smarty->assign('custname'$_POST['ename']); 
check smarty documentation for more information
http://www.smarty.net/
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");
nayes84 is offline
Reply With Quote
View Public Profile
 
Old 05-13-2010, 01:02 AM Re: Printing user name into my customized message body.
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Quote:
Originally Posted by SnapCount80 View Post
In this case, $message is the variable that displays the content of the email body. I'm not sure what 'char_input' is sending but you can just add the name into the $message variable. It could look something like this.
PHP Code:
$custname $_POST['ename'];

$message "<html>
 <body>
 <span style='font-family:Verdana, Arial, Helvetica, sans-serif;  font-size:12px; font-style:normal; font-weight:normal; color:#212121;  line-height:14px;'>
Dear " 
$custname ",</span>
<b>Welcome to our website.</b>" 

$details 
"</body>
</html>"

Thanks for your reply.... I know this is the solution but I want to send different message to different customer with different templates.....and all I want to save myself from the hassle of pasting name into body again and again......

Any other suggestion would be highly appreciated.

Thanks
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
Old 05-13-2010, 01:18 AM Re: Printing user name into my customized message body.
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Quote:
Originally Posted by nayes84 View Post
You can use a template system to do the job for you. ie. smarty templates
HTML Code:
<html>
<body>
<span style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-style:normal; font-weight:normal; color:#212121; line-height:14px;">

Dear {$custname},</span>

<b>Welcome to our website.</b>
</body>
</html>
PHP Code:
$smarty->assign('custname'$_POST['ename']); 
check smarty documentation for more information
http://www.smarty.net/
I don't understand wt u r saying....I am new to php....would u please elaborate a little bit.

Thanks.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
Old 05-16-2010, 04:45 PM Re: Printing user name into my customized message body.
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
Sorry for taking a while to reply.

well with smarty templates you can load template file which include some special variables like {$custnam} which refer to name and so on.

these special variables you should define your self in the php side to be able to use in the template

you can define (assign) that variable using the line I mentioned before
PHP Code:
$smarty->assign('custname'$_POST['ename']); 
Of course it can be any name you like like customer_name or whatever

after that you can use it in the template like what is mentioned above
say message1.html
HTML Code:
<html>
<body>
<span style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-style:normal; font-weight:normal; color:#212121; line-height:14px;">

Dear {$custname},</span>

<b>Welcome to our website.</b>
</body>
after that you can

at last you need to get the parsed version of the data using $smarty->fetch
PHP Code:
$body=$smarty->fetch('message1.html'); 
you will get in $body variable toe parsed version of the message where {$custname} is replaced with you value in $_POST['ename']

you can always use different messages by fetching different files message1.html, message2.html, and so on
of course you need to create them all before using them

hope I could clarify it.

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");

Last edited by nayes84; 05-17-2010 at 09:09 PM..
nayes84 is offline
Reply With Quote
View Public Profile
 
Old 05-17-2010, 03:51 AM Re: Printing user name into my customized message body.
Experienced Talker

Posts: 48
Name: Websys_seo
Location: India
Trades: 0
i think the suggestion provided above is quite enough.
just try to store the message and user name in different variable.

$name= $_POST['ename'];
$message= "your message or fetch this from your database";
// now for the html

$details_msg ="<html>
<body>Hello ".echo ($name);." welcome to your site name
</body></html>";
//so when you print $details_msg you will get the result.
__________________

Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Arings is offline
Reply With Quote
View Public Profile Visit Arings's homepage!
 
Reply     « Reply to Printing user name into my customized message body.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26072 seconds with 12 queries