-
Storing emails in MySQL
Hi Everyone!
Just got one question.
I'm trying to store e-mails in MySQL.
I know I can stor it as simple varchar, but I wanted to put some constraints on it.
Although I can't find any place, which give me some clear info on how to do it.
I though to do it like this
...
email varchar check(email in ('*@*.*'))
...;
Will it be correct or not? Is there a better way to do it?
P.S. For all those search Google adviser.
Please keep that advise for yourself. I ALREADY SEARCHED!
So unless you find something I didn't don't bother.
I'll go through the tutorial once again though. I might of missed something :(
-
-
this can be done in PHP before storing the addy -> http://www.sitepoint.com/article/use...il-address-php
v_Ln
-
Thanks guys. The info you gave me is very useful, but nevertheless not exactly what I need.
I'm just trying to put in some validation rules in place, so that the person who'll be looking after everything couldn't do to much harm, even if he want's to.
Couldn't trust him even a little bit with the work :(
-
Then you will need regular expressions in the scripting language you use to filter the input before it is stored the in the database.
http://www.zend.com/zend/spotlight/ev12apr.php
If you are using another lanuage, check the docs on how to use regular expressions, if it is supported.
-
Most people handle what you are trying to do in the business layer of their web application. The check you have down is about the best you can do for email address validation.
-
Hi
As it has been said, you should carefully check any input
in your database, before you actually start any communication
with it (eg. using SQL). The standard approach involves some
front end, which sends input data to a trusted application
(e.g. your server-side php script), which performs the
validation. Never ever trust client-side checks.
In addition
Scan your database regularily for entries which does not
follow your constraints. This should never happen by design,
but if, there are other data flows you are not controlling.
Search and eliminate.
Cheers.
-
Unfortunately I'm only producing the database, and will have not control over it what so ever :(