MemphiS Posted June 26, 2007 Share Posted June 26, 2007 i have a script where i check the content that the user inputs and works perfect. But ive found when i click enter for a new line it will return false how can allow a new line... Thanks Link to comment https://forums.phpfreaks.com/topic/57225-allowing-new-lines-within-comments/ Share on other sites More sharing options...
Wuhtzu Posted June 26, 2007 Share Posted June 26, 2007 Please post the code you use to validate/check the user input... Link to comment https://forums.phpfreaks.com/topic/57225-allowing-new-lines-within-comments/#findComment-282845 Share on other sites More sharing options...
MemphiS Posted July 4, 2007 Author Share Posted July 4, 2007 bumP i use ctype,str_replace for it Link to comment https://forums.phpfreaks.com/topic/57225-allowing-new-lines-within-comments/#findComment-289463 Share on other sites More sharing options...
Wuhtzu Posted July 6, 2007 Share Posted July 6, 2007 First off I hope you have solved your problem by now, but if you haven't I would suggest that you use regular expression to validate your user input since it is as configurable as anything gets... <?php $user_input = "Text of line one\ntext of line two\ntext of line three"; if(preg_match("/^[a-z0-9\s]+$/",$user_input)){ echo "User input is valid"; } else{ echo "User input not valid"; } ?> The above code checks if the user input consists of letters a-z, digits 0-9 and whitespace which includes tabs, spaces and line breaks. Link to comment https://forums.phpfreaks.com/topic/57225-allowing-new-lines-within-comments/#findComment-291570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.