I want only college students to be able to sign up my website, but I couldn't figure out how to control that. I also want .edu.fr, edu.tr or other .edu extensions to be able to join my website not just .edu's. I was thinking about using some reg-ex but I couldn't find any solution. I would be glad if someone can help me?
Shouldn't be that important but I am using PHP with laravel framework.
Most educational institutions have domain names that follow these pattern:
uni.edu
uni.edu.fr
uni.ac.uk
The following regular expression covers all such cases:
/(\.edu(\.[a-z]+)?|\.ac\.[a-z]+)$/
You can add cases to the regex as needed. Check that the email is real by sending an automated email with a confirmation link.
Corresponding PHP:
if (preg_match('/(\.edu(\.[a-zA-Z]+)?|\.ac\.[a-zA-Z]+)$/i', $domain)) {
// allow
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With