depojones Posted April 26, 2010 Share Posted April 26, 2010 Hi all, How do I output an error if my input contains any whitespace and special characters. for instance, <script>, <object>, etc Quote Link to comment Share on other sites More sharing options...
de.monkeyz Posted April 26, 2010 Share Posted April 26, 2010 regular expressions are what you need (google them). But for example, if you want to make sure a string only contains letters and numbers: if(!preg_match('/^[A-Za-z0-0]*$/', $string)) { //if contained special characters } You can use that Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 26, 2010 Share Posted April 26, 2010 You need to be more explicit on "special characters". You can either specify specific characters NOT to allow or specify the characters that ARE allowed. Quote Link to comment Share on other sites More sharing options...
depojones Posted April 26, 2010 Author Share Posted April 26, 2010 This is exactly what am looking for. Thanks for your contribution Quote Link to comment 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.