HTML free text?

Discussion in 'HTML & Website Design' started by kalle437, Jan 22, 2007.

  1. #1
    Hello!
    I have a php based site, and want the users to be able to add comments to things. But I tested to add <h1>,<b>,<iframe> and other tags to that comment, and they worked. That isn't good for the security of this site. How do I make a HTML free space, where the HTML doesn't work? Or is that not possible?

    Thanks,
    Kalle :)
     
    kalle437, Jan 22, 2007 IP
  2. audax

    audax Peon

    Messages:
    83
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    audax, Jan 22, 2007 IP
  3. kalle437

    kalle437 Peon

    Messages:
    283
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well, that wasn't really what I wanted to do, but I got help at a php forum. The solution was the following:

    
    $variable = "Comment";
    echo htmlentities($variable);
    
    
    PHP:
    That would make it display the comment, but ignore tags like <h1> and just show them as plain text, as they are shown here in the forums.
     
    kalle437, Jan 23, 2007 IP