Re: [PHP] fixing new lines from textarea in an email?
how about preg_replace('/(\\n}\\r\\n)/', 'br /', $_POST[problem]); On Sat, Jun 27, 2009 at 12:50 AM, Adam Williams awill...@mdah.state.ms.uswrote: Daniel Brown wrote: In a cursory glance, I've noticed the following code: htmlspecialchars(nl2br(str_replace('\r','',$_POST[problem]))) You are using a literal '\r' in your str_replace() function. This should instead be replaced with double quotes to translate the \r to its appropriate EOL character: htmlspecialchars(nl2br(str_replace(\r,'',$_POST[problem]))) Thanks, I didn't know that single vs double quotes in that instance made a difference. I've made the change to my code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Best Regards! Wen Dong
Re: [PHP] fixing new lines from textarea in an email?
At 11:27 AM -0500 6/26/09, Adam Williams wrote: I have staff fill out a form that contains a textarea with their problem description and emailed to me when they click submit. Staff will press enter in the text area, but I'm having problems converting the \r\n into a new line in the email that is sent to me, here is the code: -snip- Adam: There's always confusion as to what you do with data collected from a form. In your case, you just want the data sent to you via email and for the new lines to be properly converted into something that resembles what was entered, right? I think this example might help: http://www.webbytedd.com//email-form/index.php Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fixing new lines from textarea in an email?
I have staff fill out a form that contains a textarea with their problem description and emailed to me when they click submit. Staff will press enter in the text area, but I'm having problems converting the \r\n into a new line in the email that is sent to me, here is the code: $subject = new support request #.mysqli_insert_id($mysqli); $message = Hello, .$_SESSION[full_name]. has created a new support request. Please log in at a href=\http://intra/helpdesk\;MDAH Helpdesk/a. The problem request is \.htmlspecialchars(nl2br(str_replace('\r','',$_POST[problem]))).\. and the best time to contact is \.htmlspecialchars($_POST[contact_time]).\.; $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n; $headers .= From: .$_SESSION[full_name]..$_SESSION[username].@mdah.state.ms.us .\r\n .X-Mailer: PHP/ . phpversion(); mail('awill...@mdah.state.ms.us', $subject, $message, $headers); and here is an example email, notice the \n is still in the body of the email, and it needs to be converted to a new line in the email: Hello, Gwendolyn Jones has created a new support request. Please log in at MDAH Helpdesk http://intra/helpdesk. The problem request is 1 of 2 questions: I'm having trouble opening files from Jennifer, Susie, and Bill because they are working with a higher version of microsoft office. My version is 2003. Is there any way I could get an update on this?\n2 of 2 questions: I need permission to download a plug-in for the NPS site where I research NR properties.\nNeither of these questions/issues are urgent. Thanks. -Gwen. and the best time to contact is Any time, phone # is cell. why isn't nl2br converting the \n to br in the email?
Re: [PHP] fixing new lines from textarea in an email?
On Fri, Jun 26, 2009 at 12:27, Adam Williamsawill...@mdah.state.ms.us wrote: I have staff fill out a form that contains a textarea with their problem description and emailed to me when they click submit. Staff will press enter in the text area, but I'm having problems converting the \r\n into a new line in the email that is sent to me, here is the code: [snip!] In a cursory glance, I've noticed the following code: htmlspecialchars(nl2br(str_replace('\r','',$_POST[problem]))) You are using a literal '\r' in your str_replace() function. This should instead be replaced with double quotes to translate the \r to its appropriate EOL character: htmlspecialchars(nl2br(str_replace(\r,'',$_POST[problem]))) -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Ask me about our fully-managed servers and proactive management clusters starting at just $200/mo.! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fixing new lines from textarea in an email?
Daniel Brown wrote: In a cursory glance, I've noticed the following code: htmlspecialchars(nl2br(str_replace('\r','',$_POST[problem]))) You are using a literal '\r' in your str_replace() function. This should instead be replaced with double quotes to translate the \r to its appropriate EOL character: htmlspecialchars(nl2br(str_replace(\r,'',$_POST[problem]))) Thanks, I didn't know that single vs double quotes in that instance made a difference. I've made the change to my code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php