Hello
Im having trouble keeping preceeding linefeeds in an textarea.
Look at this test page
http://www.wurlygig.co.uk/test.php
The code for this page is very simple...
<?
$t = $_POST['t'];
?>
<html>
<body>
<form action="" method="POST"
<textarea rows="10" cols="60" name="t"><?=$t?></textarea>
<br/>
<input type="submit">
</form>
</body>
</html>
Enter a couple of linefeeds and then some random text, then hit submit, each time you submit a linefeed is lost?
Why is it doing this and how can I fix? My application requires preceeding linefeeds in textarea fields.
Thanks
Jake
Line breaks lost from start of textarea?
Moderator: General Moderators
-
jakeylakey
- Forum Newbie
- Posts: 2
- Joined: Fri Feb 11, 2011 1:44 pm
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Line breaks lost from start of textarea?
nl2br()
You should also consider when outputting user input to pass it through to avoid XSS injection.
You should also consider when outputting user input to pass it through
Code: Select all
htmlspecialchars($your_input, ENT_QUOTES);-
jakeylakey
- Forum Newbie
- Posts: 2
- Joined: Fri Feb 11, 2011 1:44 pm
Re: Line breaks lost from start of textarea?
This has not fixed my problem.
Html special chars didnt change anything, nl2br simply displayed this in my textarea.
<br />
<br />
<br />
rgerg
Im trying to get a textarea to display accurately the content it submitted to itself, not output to a page.
any line feeds put before any text in the textarea are lost one by one when you submit...
Html special chars didnt change anything, nl2br simply displayed this in my textarea.
<br />
<br />
<br />
rgerg
Im trying to get a textarea to display accurately the content it submitted to itself, not output to a page.
any line feeds put before any text in the textarea are lost one by one when you submit...