tags:

views:

103

answers:

1

I have a textarea input on a form for users to submit their snail mail address.
This is the code I have <textarea name="Mail" rows="4" ></textarea> I would like for the line breaks in the text area to be passed in the POST data so that the address will appear properly in the code echo $_POST['Mail'];

+2  A: 

Use this:

 print nl2br($_POST['Mail']);
Sarfraz
Also, deter XSS with: `print nl2br(htmlentities($_POST['Mail']));` To explain the nl2br() further, the problem wasn't that newlines weren't being passed from the input, it's that newlines don't display as newlines in HTML in output.
Frank Farmer
@Frank Farmer: i have kept my answer limited to the question, of course there are a host of considerations when it comes to security not just xss. thanks anyways
Sarfraz