McMaster Posted November 8, 2012 Share Posted November 8, 2012 Hi, Recently I've been working on a comment system but I'm experiencing a problem. People can post with just spaces and not actual characters / numbers. Is there any way around this? Thanks in advance. ATB Quote Link to comment https://forums.phpfreaks.com/topic/270453-can-post-comments-with-spaces-only/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 8, 2012 Share Posted November 8, 2012 As part of your filtering logic that you should apply before validating the submitted data, you should trim the values and/or filter out any characters that are not within the expected range of characters for the type of the data field. Quote Link to comment https://forums.phpfreaks.com/topic/270453-can-post-comments-with-spaces-only/#findComment-1391051 Share on other sites More sharing options...
McMaster Posted November 8, 2012 Author Share Posted November 8, 2012 Had a brainwave but probably not right... Wouldn't it be possible to use ctype_alpha() along with ctype_digit() ? Quote Link to comment https://forums.phpfreaks.com/topic/270453-can-post-comments-with-spaces-only/#findComment-1391052 Share on other sites More sharing options...
PFMaBiSmAd Posted November 8, 2012 Share Posted November 8, 2012 Since comments would normally contain white-space and punctuation, no, using those two functions wouldn't help. Quote Link to comment https://forums.phpfreaks.com/topic/270453-can-post-comments-with-spaces-only/#findComment-1391059 Share on other sites More sharing options...
McMaster Posted November 8, 2012 Author Share Posted November 8, 2012 I don't suppose you could have some sort of function that could help me out here. I've bee racking my brains here with this. Quote Link to comment https://forums.phpfreaks.com/topic/270453-can-post-comments-with-spaces-only/#findComment-1391061 Share on other sites More sharing options...
PFMaBiSmAd Posted November 8, 2012 Share Posted November 8, 2012 Someone already mentioned using trim on the data. That does assume that you are then testing to make sure that the data isn't an empty string. Quote Link to comment https://forums.phpfreaks.com/topic/270453-can-post-comments-with-spaces-only/#findComment-1391063 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.