MemphiS Posted July 28, 2007 Share Posted July 28, 2007 Every time i hit enter within my comment textfield and click submit it causes it to echo that the content is invalid. Example: TectField comment would be wrritten like so; Some comment that i wish to hit enter without an error. <?php $text = strip_tags(addslashes($_POST['textfield'])); if (!ctype_alnum(str_replace(" ", "", $text))){ echo "Bad content found"; }elseif (ctype_alnum(str_replace(" ", "", $text))){ echo "Good content"; } ?> Link to comment https://forums.phpfreaks.com/topic/62191-forum-comments/ Share on other sites More sharing options...
LiamProductions Posted July 28, 2007 Share Posted July 28, 2007 [code]<?php $text = strip_tags(addslashes($_POST['textfield'])); if (!ctype_alnum(str_replace(" ", "", $text))){ echo "Bad content found"; }elseif (ctype_alnum(str_replace(" ", "", $text))){ echo "Good content"; } change Good content to bad content found And why don't you just use If and else? ?>[/code] Link to comment https://forums.phpfreaks.com/topic/62191-forum-comments/#findComment-309598 Share on other sites More sharing options...
MemphiS Posted July 28, 2007 Author Share Posted July 28, 2007 Please think about what your posting Liam before doing so. If anyone has a useful comment... Link to comment https://forums.phpfreaks.com/topic/62191-forum-comments/#findComment-309804 Share on other sites More sharing options...
MemphiS Posted July 30, 2007 Author Share Posted July 30, 2007 bump Link to comment https://forums.phpfreaks.com/topic/62191-forum-comments/#findComment-310716 Share on other sites More sharing options...
MemphiS Posted July 30, 2007 Author Share Posted July 30, 2007 .... Link to comment https://forums.phpfreaks.com/topic/62191-forum-comments/#findComment-310843 Share on other sites More sharing options...
thedarkwinter Posted July 30, 2007 Share Posted July 30, 2007 possibly a useless suggestion try trimming, and maybe replacing windows newlines with unix newlines, or the other way round... <?php //... $text = trim(strip_tags(addslashes($_POST['textfield']))); $text = str_replace("\r\n", "\n", $text); // replace windows newline with unix... Link to comment https://forums.phpfreaks.com/topic/62191-forum-comments/#findComment-310857 Share on other sites More sharing options...
MemphiS Posted July 30, 2007 Author Share Posted July 30, 2007 hmm worth a try Link to comment https://forums.phpfreaks.com/topic/62191-forum-comments/#findComment-310863 Share on other sites More sharing options...
MemphiS Posted July 31, 2007 Author Share Posted July 31, 2007 Thanks thedarkwinter, posting the IE enter \r\n helped me work something out Link to comment https://forums.phpfreaks.com/topic/62191-forum-comments/#findComment-311757 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.