Storing text formatting such as superscript and subscript in SQL Server 2005 using PHP

I have a html form where people submit among many things an abstract for a presentation. I've come across mathematics persons who's abstracts call for super/subscripts in the text to be meaningful and correct.

I have an idea of how to do this, but was going to see if their is a easier way any professionals may know about. The page is xhtml/javascript/css, the abstracts (fancy word for description) are typed into a textarea and the form sends POST data to PHP 5.

My though was to either inform the user or provide buttons for "begin subscript" "end subscript" etc. which insert right where their cursor is "[sub]" "[/sub]" (you can imagine the same for superscript). I can't/don't wish to use regular html/xhtml tags because I strip tags on the server side as to not allow jokers to format things interestingly when page data is redisplayed. Just before the string is stored in database, along with a function to escape single quote, I would add in regular expression replace for "[sub]" and "[/sub]" etc. to become "<sub> and "</sub" etc.

This also creates more peculiarities in the fact that at a certain point I would have to go through a take out any formatting done for web displaying and change it to what would be needed for printing in a booklet.

What have others done? Does this sound like a decent approach?
justinvoelsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LordOfPortsCommented:
That approach would work, if you are using the strip_tags($text); PHP function http://us2.php.net/strip_tags to remove HTML tags it has a second optional parameter that allows you to specify which tags are allowed, e.g.:

strip_tags($text, '<sub><sup>');

This way the user or your buttons could use the real tags for editing. Another option is to use a rich text box such as TinyMCE http://tinymce.moxiecode.com/ which come with special buttons for super- and subscript, it is very easy to integrate with your existing page and shows the user actual superscripted/subscripted tags instead of the HTML tags.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
justinvoelsAuthor Commented:
Could anyone elaborate on the storing of this data in a database?
0
justinvoelsAuthor Commented:
By that I meant using tinyMCE
0
justinvoelsAuthor Commented:
Haha, my apologies, next time I promise I will click the link and read it first, I caught the name a bit late too.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.