bladez Posted September 12, 2007 Share Posted September 12, 2007 i have a form for login n password i want to validate on server site to check if the content are either characters or numbers only ... Example : Username : bladez - accecpted Username : bladez99 - accecpted Username : *>dsa*dad - Rejected Username : <?php bla ?> - rejected Which means if it doesnt meet those pattents its an error ..how do i do that in PHP? Link to comment https://forums.phpfreaks.com/topic/69063-help-pls-validating-input-boxhow/ Share on other sites More sharing options...
hackerkts Posted September 12, 2007 Share Posted September 12, 2007 You can try regex a-zA-Z0-9 Link to comment https://forums.phpfreaks.com/topic/69063-help-pls-validating-input-boxhow/#findComment-347136 Share on other sites More sharing options...
colombian Posted September 12, 2007 Share Posted September 12, 2007 To validate particular patterns, you'll need to venture into regular expressions. Here is a helpful tutorial: http://weblogtoolscollection.com/regex/regex.php Or just go to: http://us3.php.net/regex The number portion of it you can check with the is_numeric function. So <?php if (!is_numeric($POST['variable'])) { // Errors here } ?> Link to comment https://forums.phpfreaks.com/topic/69063-help-pls-validating-input-boxhow/#findComment-347137 Share on other sites More sharing options...
AdRock Posted September 12, 2007 Share Posted September 12, 2007 You can do this if(!ereg("^[A-Za-z0-9 \-]{4,30}$",$username)) The bit that does [A-Za-z0-9] will allow numbers and letters only The bit that does {4,30} allows between 4 and 30 letters/numbers and $ username is the input box name Link to comment https://forums.phpfreaks.com/topic/69063-help-pls-validating-input-boxhow/#findComment-347345 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.