#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    27
    Rep Power
    0
    How can i disable html-code-input in my php-guestbook?

    Pieter
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    I don't know of any way to keep someone from putting HTML code, although I think I saw somehting about it on www.phpbuilder.com , but you don't have to actually display it, you could just use the strip_tags function, it will take off all of the HTML and then you can just display it.

    Chris
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Sweden
    Posts
    384
    Rep Power
    15
    Hi!

    This will work greate:

    $nohtml = (ereg_replace("<", "", $nohtml));

    Where $nohtml is the variable where you donīt want html work. It will remove all <īs. Also, html vill not work.

    Best regards,
    Christoffer
    SWEDEN
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    Annapolis, Maryland US
    Posts
    113
    Rep Power
    15
    <?
    $incoming=strip_tags($incoming);

    // removes HTML tags
    ?>
    http://www.php.net/manual/function.strip-tags.php
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    ya, that is what I meant to day, if mine want' clear .

    Chrille: I have one problem with your code, it will disable the HTML, but it won't take it out, it will just remove the first bracket so you'll have all these B> /B> etc. However if you would do something like

    <?
    $nohtml = ereg_replace("<([0-9 A-Z a-z)>", "", $nohtml);
    $nohtml = ereg_replace("</([0-9 A-Z a-z)>", "", $nohtml);
    ?>

    That would probably work.

    Chris
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    Regexps are not the way to do this. There are too many things that could go wrong. PHP has the strip_tags() function which does this very nicely. Use it...
  12. #7
  13. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,642
    Rep Power
    4492
    or rather than stripping the tags,you could use htmlentities() or htmlspecialchars() to replace the brackets < and > with specials codes ;lt and ;gt. that way the text will appear exactly as they have typed it into the text box, but it won't be an active link or image...know what i mean?

    ---John Holmes...
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    13
    Rep Power
    0
    Check this page. It will teach you how to disable html code and enable ubb code. All about regular expression.
    http://www.webmasterbase.com/article...id=228&pid=807

    ------------------
    Stories OnLine
    http://www.stories-online.net/

    WARNING: adult stories!
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    32
    Rep Power
    15
    Regular expressions are unnecessary. Use either strip_tags() or htmlspecialchars() depending on how you want to handle it.
  18. #10
  19. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    Agreeing with Dwarf & Anti - use regex only when you have to.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    27
    Rep Power
    0
    thanks, this will help me very well

Similar Threads

  1. Allowing php code in html, parsers?
    By WorldBuilder in forum Apache Development
    Replies: 21
    Last Post: December 15th, 2007, 10:26 AM
  2. A lot of questions about html...i think
    By DyJohnnY in forum HTML Programming
    Replies: 1
    Last Post: February 11th, 2004, 01:23 AM
  3. Need to validate no HTML code a field
    By goiubigten in forum HTML Programming
    Replies: 1
    Last Post: February 9th, 2004, 01:04 PM
  4. HTML frames in flash, etc.
    By anubite in forum Flash Help
    Replies: 1
    Last Post: February 3rd, 2004, 12:15 AM
  5. Replies: 9
    Last Post: January 29th, 2004, 07:33 AM

IMN logo majestic logo threadwatch logo seochat tools logo