Line Breaks in a Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
the9ulaire
Forum Commoner
Posts: 74
Joined: Mon Jun 11, 2007 11:31 am

Line Breaks in a Form

Post by the9ulaire »

I have an HTML form that puts data into my MySQL database, if you add line breaks in the form it is retained in the database, but if you try to display the data it is one long string, naturally. How do I make it so that the line breaks are interpreted to "<br />"s? What would be an efficient way of creating breaks?

I currently have this:

Code: Select all

<textarea class="body" name="page_content" rows="10" cols="60"><?php echo htmlspecialchars($page_content); ?></textarea>
Thank you, in advance, for you time! It's greatly appreciated!
Luke
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

nl2br() is your friend
the9ulaire
Forum Commoner
Posts: 74
Joined: Mon Jun 11, 2007 11:31 am

Post by the9ulaire »

Thank you so much! Everything is working great!
Post Reply