1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can i modifie html code through php textarea

Discussion in 'Other Languages' started by LitNit, Sep 15, 2014.

  1. LitNit

    LitNit Newbie

    Joined:
    Aug 30, 2014
    Messages:
    9
    Likes Received:
    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: Sep 15, 2014
  2. Jezveh

    Jezveh Newbie

    Joined:
    Sep 9, 2014
    Messages:
    2
    Likes Received:
    0
    Occupation:
    Web developer
    Location:
    France
    the css style is always the same between the textarea's value ?
     
  3. Conor

    Conor Jr. VIP Jr. VIP

    Joined:
    Nov 7, 2012
    Messages:
    3,363
    Likes Received:
    5,425
    Gender:
    Male
    Location:
    South Africa
    Home Page:
    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.
     
    • Thanks Thanks x 1
    Last edited: Sep 28, 2014
  4. member8200

    member8200 Regular Member

    Joined:
    Aug 9, 2014
    Messages:
    469
    Likes Received:
    33
    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. :)