gtridez Posted July 25, 2006 Share Posted July 25, 2006 hey guys...i need to allow only certain html tags when a user submits info in a form...for example like only allow <b>, <img src".."> tags etc....i'm familiar with strip_tags function...but any way to do what i want? Quote Link to comment Share on other sites More sharing options...
trq Posted July 25, 2006 Share Posted July 25, 2006 [url=http://php.net/strip_tags]strip_tags[/url]() has an optional [i]allow tags[/i] argument. Use that. Quote Link to comment Share on other sites More sharing options...
gtridez Posted July 25, 2006 Author Share Posted July 25, 2006 thanx...anywhere i can get a little more info on that? Quote Link to comment Share on other sites More sharing options...
trq Posted July 25, 2006 Share Posted July 25, 2006 Sorry... ive never used it, your right... the manual is a little sprse there. You'll need to experement. Quote Link to comment Share on other sites More sharing options...
trq Posted July 25, 2006 Share Posted July 25, 2006 As an example.... thsi code will let the <p> and </p> tags through.[code=php:0]<?php $a = "<p>this is a paragraph</p>"; echo strip_tags($a,"<p>");?>[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted July 25, 2006 Share Posted July 25, 2006 And this lets <p> <a href=''> </a> and <p> through. Too easy.[code=php:0]<?php $a = "<p><a href=''>this is a paragrapgh</a></p>"; echo strip_tags($a,"<p><a>");?>[/code]EDIT: The [ / url] is meant to be a closing < / a >, thats the forum playin with it. Quote Link to comment Share on other sites More sharing options...
gtridez Posted July 25, 2006 Author Share Posted July 25, 2006 hey thanx alot...i think that should work Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.