How to Deny Website Access based on User's Email Address
Good Morning,
I'm starting a PHP/MySQL project that will include a registration page where the user will be prompted to enter their email address. The requirement is that certain email address domains will not be permitted access to the website. We want to disallow registration of such user's but not sure how to make this happen.
One thought was to populate a list of "bad domains" in a MySQL table, and use PHP to check the email address supplied against the "bad domain" table. If there's a match, the user i开发者_运维百科s given a message box stating that registrations aren't permitted from their email domain.
Is there another approach that is easier to manage? Are we on track with the above approach? Please let me know how you would tackle this challenge, and/or if you've had to done this before.
Thanks, Sid
You will have to hold a list of "bad domains" somewhere, and it will have to be maintained. Better in an SQL table than PHP. Seems like you are on the right track to me.
I would use a text file (Black.list) for the list of bad domains. It could be very easy to maintain this way. Otherwise, you will have to write a script to update the MYSQL database.
You could also use globbing, and allow comments in the file.
--Dave
精彩评论