Page 1 of 1

how to preserve input format..

Posted: Thu Jul 24, 2008 2:34 am
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]);
 
 
?>

Re: how to preserve input format..

Posted: Thu Jul 24, 2008 6:50 am
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.