Cless Posted June 30, 2007 Share Posted June 30, 2007 Hello, How is it possible to make it so, on a registration form, if someone doesn't enter a required amount of characters, it makes it so they can't continue to Register (they must try again)? Thanks. Link to comment https://forums.phpfreaks.com/topic/57844-solved-if-person-does-enter-more-than-x-characters-it-will-not-work/ Share on other sites More sharing options...
AndyB Posted June 30, 2007 Share Posted June 30, 2007 http://ca.php.net/manual/en/function.strlen.php Link to comment https://forums.phpfreaks.com/topic/57844-solved-if-person-does-enter-more-than-x-characters-it-will-not-work/#findComment-286603 Share on other sites More sharing options...
metrostars Posted June 30, 2007 Share Posted June 30, 2007 You could use the script like if(strlen($_POST['username']) <= 5) {echo "You must enter at least 5 characters for the username";} else { if(strlen($_POST['password']) <= 5) {echo "You must enter at least 5 characters for the password";} else { continue registration; }} or if you want the same error for each one, if(strlen($_POST['username']) <= 5 || strlen($_POSt['password']) <= 5) {echo "There is a problem with registation";} else { continue script; } Link to comment https://forums.phpfreaks.com/topic/57844-solved-if-person-does-enter-more-than-x-characters-it-will-not-work/#findComment-286605 Share on other sites More sharing options...
Cless Posted June 30, 2007 Author Share Posted June 30, 2007 Ah, so that's what strlen can be used for. My friend and I thought it had barely any point. Hmm, I'll try it, metrostars. Thanks. Awesome. It worked perfectly. Thank you. Solved. Link to comment https://forums.phpfreaks.com/topic/57844-solved-if-person-does-enter-more-than-x-characters-it-will-not-work/#findComment-286607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.