0

I am saving the content from the textarea its just saving this as plane text in database not like shown in preview how to store data shown in preview

//in form;
<textarea id="wmd-input" class="wmd-panel" name="content" ></textarea>

//in database
$content =  $_POST["content"] ;
StaticVariable
  • 5,253
  • 4
  • 23
  • 45
  • 3
    You should really store the markdown source and not the generated HTML code. Perform the final rendering on the server and don't forget to sanitize the HTML in case your markdown renderer doesn't already do that. – ThiefMaster Jun 05 '12 at 11:59
  • a good suggesion by @ThiefMaster. – Raab Jun 05 '12 at 12:09
  • @Mayankswami: The textarea contains the markdown code. I know what his question is and since he shouldn't do that in the first place I posted that comment. – ThiefMaster Jun 05 '12 at 13:27

2 Answers2

0

Please look at this..

Inserting text from textarea into MySQL database without losing formatting

Its the same issue like you have.

Kindly try this if fulfill your need..

$content = nl2br($_POST["content"]);

Use this before you save in DB if you want to display the content in HTML so that all new line character will be converted into <br/>. And Save as it is (without nl2br) if you want it to display again in textarea.

Community
  • 1
  • 1
manurajhada
  • 5,284
  • 3
  • 24
  • 43
0

you can do this by markdown.php you need to download and include the markdown.php and

you just need to do

$my_html=  Markdown($content);

and now store the $my_html to database now it will work

NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143