mrjameer Posted October 27, 2006 Share Posted October 27, 2006 hi,can anybody please tell me how to avoid the user from entering any html code like '<','>', any other malicious characters in textarea using php.thanksmrjameer Link to comment https://forums.phpfreaks.com/topic/25280-validating-textarea/ Share on other sites More sharing options...
redarrow Posted October 27, 2006 Share Posted October 27, 2006 The main issue is to protect the database entrys so i advise to use the following.addslasshestrimAlso you can use all these from the link as i have provided.http://uk2.php.net/addslashesif both the examples below if the users has a < or > there be an error message.good luck hope you understand all the best redarrow.example1 for eregi.[code]<?php$mes="hi there i am redarrow";$ban=array('<','>');foreach($ban as $x){if(eregi($x,$mes)){echo " bad word please try agin";exit;} } echo "good words congratulations";?>[/code]heres a quick form example[code]<?phpif($_POST['submit']){$ban=array('<','>');foreach($ban as $x){if(eregi($x,$mes)){echo " bad word please try agin";exit;} } echo "good words congratulations";}?><form method="POST" action""><br>please tell me what you thinkof my site!<br><input type="text" name="mes"><br><br><input type="submit" name="submit" value="valadate words"><br></form>[/code] Link to comment https://forums.phpfreaks.com/topic/25280-validating-textarea/#findComment-115266 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.