pappakaka Posted February 9, 2011 Share Posted February 9, 2011 I can't get these two if, elseif and else statements too work, here is the code: if(empty($this->password)){ $this->errors[] = 'You must enter a password!'; } elseif(!strlen($this->password) >= 6){ $this->errors[] = 'Your password must be longer than 6 characters!'; } if(empty($this->email)){ $this->errors[] = 'You must enter an email address!'; } elseif(!preg_match('/^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]{2,4}$/',$this->email)){ $this->errors[] = 'Your password can only contain these characters: a-z, A-Z and 0-9!'; } if(empty($this->confemail)){ $this->errors[] = 'Please confirm your email address!'; } elseif(!$this->confemail == $this->email){ $this->errors[] = 'The email addresses you entered did not match!'; } The if and elseif statements for "email" work just fine but the other 2 doesn't. With the "password" i first want to check if the field is empty, and when it is, it works as it should. But when i for example type "test" too check if the password is longer than 6 characters i don't get any message at all? With the "confemail" i want to first check if the field is empty, and when it is, it works as it should. But when i type in "test@test.com" in both fields to try to compare "confemail" to "email" i still get the "Please confirm your email address!" message? Quote Link to comment Share on other sites More sharing options...
Fergal Andrews Posted February 9, 2011 Share Posted February 9, 2011 Hi pappakaka, Try changing your conditional operators like this: elseif(!strlen($this->password) >= 6) to elseif (strlen($this->password) < 6) and elseif(!$this->confemail == $this->email) to elseif ($this->confemail != $this->email) cheers, Fergal Quote Link to comment Share on other sites More sharing options...
pappakaka Posted February 9, 2011 Author Share Posted February 9, 2011 Ohh, so easy, that was it, solved! Big thanks! Quote Link to comment 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.