Hi everyone, I need help with regular expressions in PHP using the preg_match() function. I know how to allow only certain letters, numbers and/or characters. I need to be able to only allow only a set number of letters or numbers in an input field (for example, 3 or 4). here is the code that I have so far: // if the email field is empty, kill the function and display a message if(!$email){ die('Enter a name'); } // allows only lower and uppercase letters and numbers elseif(preg_match('/[^a-zA-Z0-9]/', $email)){ die('Enter a valid email'); } // outputs the email entered else{ echo "Email: $email"; } PHP: Thank You
// if the email field is empty, kill the function and display a message if(!$email){ die('Enter a name'); } // allows only lower and uppercase letters and numbers elseif(!preg_match('/^[a-z0-9]{3,4}$/i', $email_a)){ die('Enter a valid email'); } // outputs the email entered else{ echo "Email: $email"; } PHP: