PHP form to parse html

My question is if there is a relatively easy way for my site to preserve xcel, word and other formatted documents, including html formatting. Right now my form removes all formatting and I was thinking perhaps that somebody has a function I could use or something...
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

rae_raeAuthor Commented:
I've seen a program that somehow loads a blank html document into the form textarea...
My form is laid out like this:
            // For news forms---------------------------------------------------------------------
            case 'form_news':
            echo '<table border="0"><tr><td><align="left">';
            echo '<form action="processor.php?sender=ins_news" method="post">';
            echo '<fieldset>';
            echo '<legend>Insert New News Section</legend>';
            echo 'News Title:';
            echo '<br><input type="text" name="content_name"><br>';
            echo 'News Body:';
            echo '<br><textarea rows="8" cols="30" name="content_body"></textarea><br>';
            echo 'Positon [100 shows before 200]:<br>';
            echo '<input type="text" size="3" name="content_position">';
            echo '<input type="Submit" value="Submit">';
            echo '<input type="Reset">';
            echo '</form>';
            echo '</fieldset>';
            echo '</td></tr></table>';
            $displ_query  = "SELECT content_name, content_position FROM News_Content ORDER BY content_position";
            $result       = mysql_query($displ_query);
            echo '<font size="2"><b>News Title and Section Position Already entered:</b></font><br>';
            while($row = mysql_fetch_array($result, MYSQL_ASSOC))
                        echo "<font size='2'> {$row['content_name']} {$row['content_position']} </font><br>";
            echo '<a href="processor.php?sender=cpanel">Back to Admin Panel</a>';
            // ----------------------------------------------------------------------------------
of couse, make header actually contain the css and regular <html><body> and make_footer contains </body></html>
it is NOT POSSIBLE to maintain any external formatting inside a standard <textarea> element. This element could be styled, but after this, the style is uniform for the whole <textarea> element. it is POSSIBLE to create a special DHTML "textarea" to achieve this goal. Some online HTML editors use this strategy. You can use AJAX technology to achieve your goal, too (but this is a little bit more complicated).
(Or an applet)
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

I'm not sure I fully understand you're question, but maybe it will become clearer as I try to answer. I have to assume that you have some web form that allows users to input data, or possibly upload files, and then it parses that data and stores it somewhere. IF you allow them to upload files (e.g. Word documents in the .doc format or Excel documents in the .xls format), while nothing is impossible, it's practically impossible to keep any of the proprietary formatting that DOC and XLS use. If you've ever looked at one of those files using a plain-text editor like Notepad, you'll quickly see that the true formatting used would be an absolute nightmare to deal with.

However, if you're not uploading files and you're merely letting users input things on the web (for instance, in a textarea element as some people have mentioned), then the clear answer is to use a WYSIWYG input form. There are many of these freely available on the internet, I prefer this one myself:

These use JavaScript to let users input "rich text," so that "what you see is what you get." If you have created a document in Word, you may literally copy/paste it into one of these WYSIWYG editors and will look exactly the same. Likewise with Excel. The JavaScript changes the Word or Excel format into HTML, and then if you submit that form to a PHP script, what you get is a bunch of text with HTML formatting. If you wanted ONLY the text part and none of the formatting, you could use PHP's built-in function strip_tags() to remove the HTML. Otherwise, the data would be saved along with any formatting, so that when you output it in the web browser, it would look exactly like it did in Word in Excel (more or less).

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
rae_raeAuthor Commented:
How can I check for the existence of a string of characters within a php variable? Thanks!
There are many functions to do this sort of thing. Since there are myriad ways of "checking for existence," I'll name a few and briefly describe them.

if ( isset($var) )
    // If $var has been assigned to literally anything at all

if ( strlen($var) )
    // If $var has a "string length" greater than zero, this is true
    // This one is a stronger test than isset(), but please note
    // that integers have "string length" values as well. For instance,
    // strlen(29) == 2, because it would convert 29 to "29"

if ( !empty($var) )
    // empty() checks to see whether the variable is empty or not. (duh)
    // This conditional is the negation of that.

if ( is_string($var) )
    // For obvious reasons, this one is probably the most reliable for
    // checking whether $var is a string or not. This one's even stronger
    // than strlen(), because it would return FALSE if an integer was entered.
    // However, is_string("") returns TRUE (for the empty string). It does return
    // false for this, though: is_string(NULL)

I frequently use "if ( strlen($var) )" to test for things, because it's nice and clean. It only requires that the input has length greater than zero. I'd recommend to use that one, anyway. If you really, really, really want to ensure that your input is not strictly a number, then use is_string, but otherwise strlen() is fine.

Browse on over to They have a search engine on the top right that lets you look through every single function that is defined in PHP with elaborate explanations for each and a list of similar functions on the left side. It's really quite helpful.
rae_raeAuthor Commented:
Thanks Soapergem for your invaluable help and willingness to explain things! I'll definately give all this a wirl and see what I can come up with.
Maybe you could give it a 'whirl' as well. ;)
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
Web Development Software

From novice to tech pro — start learning today.