Guest upirate Posted April 9, 2007 Share Posted April 9, 2007 Pretty much user gets to a page where there are text boxes and text areas. Now I understand that I can do a strip_html and possibly take out any malicious input. What else can I do ? I do want the user to be able to atleast go to next line and maybe bold the text. Problem is that when user enters data in the text area, well it doesnt remember the next lines and join all of them together. any ideas ? Link to comment https://forums.phpfreaks.com/topic/46200-how-can-i-make-my-text-boxes-and-text-areas-more-secure/ Share on other sites More sharing options...
MadTechie Posted April 9, 2007 Share Posted April 9, 2007 have you tried using nl2br <?php echo nl2br("hello\nworld"); ?> hello\nworld be comes hello<br>world basically filtering can be a pain if you want to accept some html, i nomally replace <B> & </B> with [b] & [/b] then replace back so bold will work bit other html statements like will not Link to comment https://forums.phpfreaks.com/topic/46200-how-can-i-make-my-text-boxes-and-text-areas-more-secure/#findComment-224615 Share on other sites More sharing options...
Demonic Posted April 9, 2007 Share Posted April 9, 2007 $post = htmlspecialchars(htmlentities(strip_tags(mysql_real_escape_string($_POST['inputname'])))); ^Pretty decent for security. Link to comment https://forums.phpfreaks.com/topic/46200-how-can-i-make-my-text-boxes-and-text-areas-more-secure/#findComment-224619 Share on other sites More sharing options...
MadTechie Posted April 9, 2007 Share Posted April 9, 2007 this is better $string = preg_replace("/[^a-zA-Z0-9]/", "", $string); Link to comment https://forums.phpfreaks.com/topic/46200-how-can-i-make-my-text-boxes-and-text-areas-more-secure/#findComment-224624 Share on other sites More sharing options...
Guest upirate Posted April 9, 2007 Share Posted April 9, 2007 so use $string = preg_replace("/[^a-zA-Z0-9]/", "", $string); how would I also allow "[" and "]" weount I need that for my "" and "" Link to comment https://forums.phpfreaks.com/topic/46200-how-can-i-make-my-text-boxes-and-text-areas-more-secure/#findComment-224640 Share on other sites More sharing options...
neel_basu Posted April 9, 2007 Share Posted April 9, 2007 You can validate the fields before processing. you just need to modify your HTML. Link to comment https://forums.phpfreaks.com/topic/46200-how-can-i-make-my-text-boxes-and-text-areas-more-secure/#findComment-224762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.