if you are a webmaster or a web developer programmer in php/mysql you've probably noticed that when you enter the data from a fom into mysql database, its not the same as you entered in the form.

to explain better what i am talking about, lets say i have a web form with a text area, the text area asks for the user's comments. so lets say my comments are as follows:

QUOTE:
Hi, I am writing this short paragraph, this is the first line.
This is the second line of the paragraph

I skipped line 3 and started on line 4
This is line 5 now
Line 6 is the end of my paragraph

now when you enter the data into mysql database and you retrieve it from your table and display it on your web page this is how it comes out:
QUOTE:
Hi, I am writing this short paragraph, this is the first line. This is the second line of the paragraphI skipped line 3 and started on line 4 This is line 5 now Line 6 is the end of my paragraph

As you can see, its all together without any line breaks, it doesn't show the return (enter) keystrokes and it show all in one line. I wrote up a little script to show how you can write a PHP code to display the content as it is entered in the form from the user.

first, open your text editor, i am using windows xp, so i will be using notepad. so if you are using windows open a new notepad and copy and paste the following code:

CODE:
<?
########################################################################################
############## THIS SCRIPT WAS WRITTEN BY WWW.WEBUNE.COM SUPPORT #######################
############## PHP HOSTING PROVIDED BY HTTP://WWW.WEBUNE.COM     #######################
########################################################################################
?>
<html>
<head>
<title>How to show the real text entered in a form by wallpaperama</title>
</head>

<body>
<?
$format_textfield = mysql_real_escape_string($_POST[textfield]);
$format_textfield = str_replace("\\r\\n",'<br>',$format_textfield);
?>

<strong>How to show the real text entered in a form by wallpaperama <a href="http://www.wallpaperama.com">WALLPAPERAMA.COM</a></strong>
<HR>
<strong><em>Formatted Text:</em></strong><br>
<br>
<? echo $format_textfield; ?><br><hr>
<form name="form1" method="post" action="">
  <p>Enter A Paragraph Here:<br>
    <textarea name="textfield" cols="35" rows="5"><? echo htmlspecialchars($textfield); ?></textarea>
</p>
  <p>
    <input type="submit" name="Submit" value="Submit">
</p>
</form>
<div align="center">PHP hosting by <a href="http://www.webune.com">Webune.com</a></div>
</body>
</html>


once you have paste this code into your text editor, save as format.php and upload to your website. NOTE: you MUST have PHP on your website, if you don't have PHP, you can visit our friends at www.webune.com and signup with one of their popular PHP plans.

open format.php with your browser once you have uploaded to your site. you will be presented with a form. enter a paragraph with line breaks and you will see it formatted exactly as it was entered. this is a simple text editor script code in php you can use to learn how you can apply it to your website, it shows the basic on how to do make a simple to use text editor into your web forms.