imarockstar Posted December 12, 2008 Share Posted December 12, 2008 I have a form that allows people to post content in a regular TEXTAREA : <h2 class='boxtitle'>Meta Description</h2> <textarea class=editblocktext name='metadesc' > <? echo $rows['metadesc']; ?> </textarea> <br><br> but I do not want the user to throw any html,css,php or javascript in there .. how can this be prevented ? thx b Link to comment https://forums.phpfreaks.com/topic/136728-not-allowing-html-in-a-text-area/ Share on other sites More sharing options...
ted_chou12 Posted December 12, 2008 Share Posted December 12, 2008 <h2 class='boxtitle'>Meta Description</h2> <textarea class=editblocktext name='metadesc' > <? echo htmlentities($rows['metadesc']); ?> </textarea> <br><br> Ted Link to comment https://forums.phpfreaks.com/topic/136728-not-allowing-html-in-a-text-area/#findComment-714029 Share on other sites More sharing options...
Caesar Posted December 12, 2008 Share Posted December 12, 2008 <?php $message = htmlspecialchars(strip_tags($_POST['message'])); ?> Link to comment https://forums.phpfreaks.com/topic/136728-not-allowing-html-in-a-text-area/#findComment-714030 Share on other sites More sharing options...
Caesar Posted December 12, 2008 Share Posted December 12, 2008 http://us2.php.net/strip_tags For more info on strip_tags() Link to comment https://forums.phpfreaks.com/topic/136728-not-allowing-html-in-a-text-area/#findComment-714031 Share on other sites More sharing options...
imarockstar Posted December 12, 2008 Author Share Posted December 12, 2008 awesome .. i knew it was something like that .. I just had the wrong function .. what would be the correct IF statement to send an error message that you entered HTML and that it is not allowed ? like -- IF 'html code is entered' echo "you can not enter html code"; Link to comment https://forums.phpfreaks.com/topic/136728-not-allowing-html-in-a-text-area/#findComment-714102 Share on other sites More sharing options...
elite_prodigy Posted December 12, 2008 Share Posted December 12, 2008 Try: if(strip_tags($string)){ echo 'No HTML!'; } Otherwise, you'll mostlikely need to search the string for a <> pair and return the error. I would just put a notice above the textbox. Link to comment https://forums.phpfreaks.com/topic/136728-not-allowing-html-in-a-text-area/#findComment-714114 Share on other sites More sharing options...
imarockstar Posted December 12, 2008 Author Share Posted December 12, 2008 so if I want to allow html tags but not JAVAScript or PHP ... do I have to use the "allowed tags" function ? b Link to comment https://forums.phpfreaks.com/topic/136728-not-allowing-html-in-a-text-area/#findComment-714125 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.