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. 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. 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) Link to comment https://forums.phpfreaks.com/topic/150188-if-statement-post-problems/#findComment-788745 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.