I cant get this code to print the error message. I'm fairly new to php so go easy on me aha. I'm trying to make a register page for my website, feel free to request more of the code if it's required to help me.
try {
//Username
if(strlen($username) < 4) {
throw new Exception('Username must be at least 4 Characters!');
}
if(strlen($username) > 16){
throw new Exception('Username cannot be more than 15 characters!');
}
if(!ctype_alnum($username)) {
throw new Exception('Username must only be letters or numbers');
}
// Password
if(strlen($password) < 8) {
throw new Exception('Password must be at least 8 characters!');
}
// email
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
throw new Exception('Invalid Email!');
}
// secretcode
if(strlen($secretcode) < 6) {
throw new Exception('Secret Code is too short!');
}
if(strlen($secretcode) > 10) {
throw new Exception('Secret Code is too long!');
}
//repassword
if(strlen($password!=$repassword)) {
throw new Exception('Passwords did not match');
}
// Submit to database
echo 'ok';
} catch (Exception $e) {
echo $e->getMessage();
}
Can't get echo to print out error message