Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- Sanitizing


Matthew1980 - 7:49 am on Oct 5, 2010 (gmt 0)


Hi there Adam5000,

This is where you need to have the preg_match("\\", $input) function in use so that you can 'filter' out any chars that you don't want. So:-

if ((preg_match("/^[\/*]+$/m", $_POST['user_name']) || (preg_match("/^[\/*]+$/m", $_POST['psword']))){
//pattern has matched
}
else{
//pattern not matched
}

Right, I'll call this pseudo code, as regex patterns are NOT my strong suite, you may need to play with it (I guess as Rocknbil would point out the error's in my patterns ;-)) Hopefully you get the idea of what I am trying to convey.

I would suggest as you decide what you would want to call *allowed* chars then tweak the pattern from that..

Hope that makes sense anyway.

Cheers,
MRb


Thread source:: http://www.webmasterworld.com/php/4211280.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com