Bopo Posted March 19, 2009 Share Posted March 19, 2009 Hi Basically I have a username and password form therefore assume two textboxes and a button, I have written several if statements for validation purposes, however even when I know validation has been passed, the messages still appear. <?php if(isset($_POST['submit'])) { $message=""; // this will hold the error msg $username = ($_POST['username']); $password = ($_POST['password']); if(strlen($username < 5)) { $message = "Your username must be over 5 characters long"; echo "$message"; exit(); } if(strlen($password < 5)) { $message= "Your password must be over 5 characters long"; echo "$message"; exit(); } // regular expression to ensure only upercase & lowercase characters are used if(ereg('[^A-Za-z0-9]', $username)) $message = "Please user uppercase & lowercase a to z characters"; echo "$message"; exit(); } ?> Any help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/150188-if-statement-post-problems/ Share on other sites More sharing options...
Kalland Posted March 19, 2009 Share Posted March 19, 2009 Seems like you forgot { in the last if-statement. Quote Link to comment https://forums.phpfreaks.com/topic/150188-if-statement-post-problems/#findComment-788744 Share on other sites More sharing options...
Maq Posted March 19, 2009 Share Posted March 19, 2009 These: if(strlen($username [code]if(strlen($password should be: [code]if(strlen($username) [code]if(strlen($password) Quote Link to comment https://forums.phpfreaks.com/topic/150188-if-statement-post-problems/#findComment-788745 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.