How can i modifie html code through php textarea

LitNit

Newbie
Joined
Aug 30, 2014
Messages
9
Reaction score
8
Hello there !
I have 2 little big problems and i don't know how to solve them and i need someone to explain this to me step by step .
I want to write in a textarea:
Code:
<div class="example"><p class="paragraph">This is a paragraph</p></div>
and when it will be post on the html i want to recognize the div and the paragraph and to show only : "This is a paragraph" (with the css styles applied to the classes) not :
<div class="example"><p class="paragraph">This is a paragraph</p></div> (which should be on in the html code not as plain text )
Also I need this to be incremented on the database ( this is another thing but if i solve the first one i think this one is easy-peasy and will not be that hard )
I'm a php newbie and i kinda need this for a project ...
Thanks !!!
Ps: sorry for my bad english ( it's not my native language )
 
Last edited:
the css style is always the same between the textarea's value ?
 
OP, I think you'll need to give a little more context here. I'm assuming you're trying to make some sort of comment box that allows HTML tags, correct?

If so, I'd suggest migrating to Wordpress and following this guide: http://crunchify.com/the-best-way-to-allow-html-tags-in-wordpress-comment-form/

Edit: I've done a bit more research, and I think this might be what you're looking for: http://www.sutanaryan.com/php-and-mysql-comment-form-without-refreshing-page-with-jquery/

Simply replace this line:
Code:
$comment = htmlentities(addslashes(trim($_POST['message'])));

With something like this:
Code:
$comment = strip_tags($_POST['message'], '<li><a>'); // Tags you don't want to allow in your form.

I'm not a PHP expert, so someone may need to verify my code for me, but I'm fairly certain it should work.
 
Last edited:
It wasn't really clear to me on what you are trying to achieve,


1. Do you what to remove all the tags that might be incorporated on the inputs?
if so, then you can use strip_tags() to do the job.


2. or you want the format(tags and css) to be displayed as html and css and not as plain text.
Just echo out $_POST['message'] and all of the tags will be recognize as html/css tags on the webpage.

hope i made myself clear. Goodluck. :)
 
Back
Top