Well, first, you need to input the data via <textarea> type input fields. That'll presevre the formatting (but I assume you're doing that).
Next, look into using preg_replace (
http://uk.php.net/manual/en/function.preg-replace.php) and using a list of the control codes (e.g. /t for tab, /r or /n for newline - or both on WierdOS, of course!) and replaceing them with <br>s, sets of 's, etc..
Here's a reply I wrote ages ago, to this effect. That 'rich_text_format' function might be something like what you need:
http://p2p.wrox.com/topic.asp?TOPIC_...ch_text_format