AndrewJ1313 Posted October 28, 2009 Share Posted October 28, 2009 I have a form and after users submit the data, I want to organize all of the submitted data into a clean and easy to read message which will be email to me. Here is my code: $message = 'Property id: ' . $_POST['id'] . '\n'; $message .= 'Property name: ' . $_POST['property_name'] . '\n'; $message .= 'Address: ' . $_POST['address'] . '\n'; $message .= 'City, State ZIP: ' . $_POST['city'] . ', ' . $_POST['state'] . ' '. $_POST['zip'] . '\n'; $message .= 'Phone number: ' . $_POST['phone'] . '\n'; $message .= 'Fax number: ' . $_POST['fax'] . '\n'; $message .= 'Image 1: ' . $_POST['image1'] . '\n'; $message .= 'Image 2: ' . $_POST['image2'] . '\n'; $message .= 'Image 3: ' . $_POST['image3'] . '\n'; My problem is that instead of creating each item on it's own line, the email is being sent like: "Property id: 255\nProperty name: XXXX\nAddress: 123 Main Street\nCity, State ZIP: Sometown, State ZIP\nPhone number: 555-555-5555\nFax number: 555-555-5555\nImage 1: test\nImage 2: test\nImage 3: test\n" Is there something I am doing wrong with the use of the new line (\n) code? I am working in PHP 5. Thanks to all who respond, Andrew Quote Link to comment Share on other sites More sharing options...
Adam Posted October 28, 2009 Share Posted October 28, 2009 Special characters like the new line character must be within double quotes... $message = 'Property id: ' . $_POST['id'] . "\n"; Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 28, 2009 Share Posted October 28, 2009 and i think windows systems is /n/r Quote Link to comment Share on other sites More sharing options...
AndrewJ1313 Posted October 29, 2009 Author Share Posted October 29, 2009 Thanks! That did it. For whatever reason though, "\n" prevents the email from being sent, I had to use "\r" in double quotes. Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 29, 2009 Share Posted October 29, 2009 Thanks! That did it. For whatever reason though, "\n" prevents the email from being sent, I had to use "\r" in double quotes. use \n\r if you can Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.