how to preserve input format..

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
fird01
Forum Newbie
Posts: 19
Joined: Mon Apr 07, 2008 11:04 pm

how to preserve input format..

Post by fird01 »

if the data is input with paragraph, spaces, bold or .... i want to output the data with those criteria intact..
because when i used textarea.. the output will always come out in one line only .
my current code.. im expecting to save the data into mysql.. but cant even ouput with the right format..

Code: Select all

<div id="newsContent">
<form action="t8.php" method="post" name="fnews"   >
  <p>
  Title: <input width="500" name="newsTitle" id="newsTitle" type="text">
  </p>
  <p><textarea name="newsText" id="newsText" cols="100" rows="20"></textarea> </p>
  <p>
    
    <input type="submit" name="button" id="button" value="Submit">
    
  </p>
  </form>
</div>
<?
$newsTitle=$_POST[newsTitle];
echo htmlspecialchars($_POST[newsText]);
 
 
?>
manixrock
Forum Commoner
Posts: 45
Joined: Sun Jul 20, 2008 6:38 pm

Re: how to preserve input format..

Post by manixrock »

<textarea> inputs give you a simple text output, no html processing. When you want to print the simple text into a html page, you should put it inside a <pre> tag to preserve it's formatting (like tabs, newlines). However, no html formatting is allowed inside a textarea, so no paragraphs, bold, or other.

You may want to check out http://tinymce.moxiecode.com/ for a free, good WYSIWYG editor in html.
Post Reply