Technex Posted August 12, 2007 Share Posted August 12, 2007 Hey guys I javascript:void(0); Coolhope you can guess what I'm trying to do just by seeing this: if(substr($_POST['regusername'],0,25)==TRUE){ echo 'Username is good under 25'; }else{ echo 'Username is bad more than 25'; } Just doesn't work I think what I'm trying to == to is wrong. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/64545-solved-ifsubstr-etc-how-to-tell-if-username-is-under-limit-and-display-error/ Share on other sites More sharing options...
cooldude832 Posted August 12, 2007 Share Posted August 12, 2007 No i can' tell what you are doing, are you trying to get the length of user name so they can't have names >25 characters? Quote Link to comment https://forums.phpfreaks.com/topic/64545-solved-ifsubstr-etc-how-to-tell-if-username-is-under-limit-and-display-error/#findComment-321740 Share on other sites More sharing options...
Technex Posted August 12, 2007 Author Share Posted August 12, 2007 Sorry lemme explain it more. I already know how to limit the username by using this: $regusername = substr($_POST['regusername'],0,25); But if a user goes over this limit it just cuts there username down to 25 and doesn't tell them or stop them from registering. How can I display a error and stop the code? (by using a if statement if possible) Quote Link to comment https://forums.phpfreaks.com/topic/64545-solved-ifsubstr-etc-how-to-tell-if-username-is-under-limit-and-display-error/#findComment-321743 Share on other sites More sharing options...
lewis987 Posted August 12, 2007 Share Posted August 12, 2007 if(strlen($regusername) <= 25){ //Code } else { //code } strlen() check the length of a string... that WILL work if you use the correct var.. Quote Link to comment https://forums.phpfreaks.com/topic/64545-solved-ifsubstr-etc-how-to-tell-if-username-is-under-limit-and-display-error/#findComment-321745 Share on other sites More sharing options...
Technex Posted August 12, 2007 Author Share Posted August 12, 2007 Thanks mate, solved. Nice surprise coming up on MSN with that code also . Quote Link to comment https://forums.phpfreaks.com/topic/64545-solved-ifsubstr-etc-how-to-tell-if-username-is-under-limit-and-display-error/#findComment-321754 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.