PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 13th, 2009, 09:59 AM
AnonG AnonG is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 56 AnonG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 54 m 52 sec
Reputation Power: 1
Contact Form, Remove \r\n

Hi all,

I'm getting frustrated with these \r\n thingies. When I submit my contact form and the email gets sent to me it looks like this.

Message: bu hu \r\nbu hu\r\nbu hu\r\nbu hu\r\n\r\nbu

When it should look like:
bu hu

bu hu..

(Testing only).

I've tried nl2br but that places in <br /> and doesn't make chars go into a new line when I check my mail.

Any ideas?

Reply With Quote
  #2  
Old October 13th, 2009, 10:42 AM
MatthewJ MatthewJ is offline
Contributing User
Click here for more information.
 
Join Date: May 2007
Location: Davenport, Iowa
Posts: 564 MatthewJ User rank is Private First Class (20 - 50 Reputation Level)MatthewJ User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 21 h 23 m 29 sec
Reputation Power: 3
If you are seeing the break tags, it is because you are sending the email as plain text. You need to send in html format if you want breaks to work.

http://us.php.net/manual/en/function.mail.php

Example 4 should help

Reply With Quote
  #3  
Old October 13th, 2009, 11:57 AM
AnonG AnonG is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 56 AnonG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 54 m 52 sec
Reputation Power: 1
I've tried what you suggest but now I can't get nl2br() to put <br /> there instead of \r\n. It does nothing and leaves the same string as before.

But email is being sent as HTML tho. Just doesn't change \r\n to <br />.

Reply With Quote
  #4  
Old October 13th, 2009, 01:42 PM
MatthewJ MatthewJ is offline
Contributing User
Click here for more information.
 
Join Date: May 2007
Location: Davenport, Iowa
Posts: 564 MatthewJ User rank is Private First Class (20 - 50 Reputation Level)MatthewJ User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 21 h 23 m 29 sec
Reputation Power: 3
Code:
$data = str_replace("\r\n", "<br />", $data);


Give that a whack

Reply With Quote
  #5  
Old October 13th, 2009, 03:20 PM
IAmALlama IAmALlama is offline
Me
Click here for more information. Click here for more information
Click here for more information
 
Join Date: Apr 2007
Location: Seattle, WA
Posts: 1,937 IAmALlama User rank is Private First Class (20 - 50 Reputation Level)IAmALlama User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 5 Days 1 h 54 m 18 sec
Reputation Power: 4
chances are if he is actually seeing the \r\n then he is using addslashes() on the string prior to adding it to a database and the back slashes are getting escaped. seems to me he should strip the slashes and then \r\n shouldn't show in the message.

Reply With Quote
  #6  
Old October 22nd, 2009, 02:27 PM
AnonG AnonG is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 56 AnonG User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 h 54 m 52 sec
Reputation Power: 1
Sorry for the delay.

The problem with \r\n was that I used mysql_real_escape_string on $_POST['something'].

Message is now being sent in html form just fine. Only problem is that subject and message parts aren't sent in UTF-8 afaik. Gmail doesn't display these characters "ž ć č š đ" eventhough charset is set to UTF-8.

Here's the code I'm using.

PHP Code:
 $Od $Posiljatelj;
         
$Za $Prejemnik["Uporabnik_ePosta"];

         
$Vsebina "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /></head><body><p>" nl2br($Vsebina) . "</p></body></html>";

         
$mime = new Mail_mime;
         
$mime->setHTMLBody($Vsebina);

         
$Podatki = array('From' => $Od,
                          
'To' => $Za,
                          
'Subject' => $Naslov);

         
$Vsebina $mime->get();
         
$Podatki $mime->headers($Podatki);

         
$mail =& Mail::factory('mail');
         
$mail->send($Za$Podatki$Vsebina); 


Any ideas on what could be wrong?

Thankyou in advance.

Last edited by AnonG : October 22nd, 2009 at 02:28 PM. Reason: typos

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Contact Form, Remove \r\n


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek