I have the following code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org
/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="RLJ RLJ" />
<title>Untitled 2</title>
</head>
<body>
<form action=SCRIPT.php method=POST>
<textarea name="pastwork" id="pastwork" rows="6" wrap="hard" style="border: 1px solid
#808080; width:85px; padding: 5px;"></textarea>
<input type="submit" value = "Submit"/>
</form>
</body>
</html>
where SCRIPT.php is as follows:
<?php
$pastwork = $_POST['pastwork'];
echo "<pre>". $pastwork."</pre>";
echo "<br />";
echo nl2br($pastwork);
?>
The problem I am having is that line breaks aren't properly passed on in Firefox. When I type the following into the textarea (B denotes the character that causes the cursor to jump to the next line, N denotes the character that causes that word to jump to the next line):
ddddddddddBdd fff
ggg ggg ggNgg sss
i.e. the textarea looks like this:
+------------+
| dddddddddd |
| Bdd fff |
| ggg ggg |
| ggNgg sss |
+------------+
Internet Explorer echoes it as:
ddddddddd
Bdd fff
ggg ggg
ggNgg sss
which is correct, with line breaks exactly where they were in the textarea.
However, Firefox echoes it as:
ddddddddddN fff
ggg ggg ggNgg sss
whether I use nl2br()
or pre
tags.
(I haven't tried any other browsers yet)
Could somebody please tell me why this is and how to make sure line breaks are properly passed on, regardless of the browser.