This looks like an example from the sql-injection tutorial. If you need to integrate user input into a database query, you should always consider the following two security measures. Both should be applied, if possible, just in case:
- Use prepared statements (if your database driver supports this)
- Perform input validation
You should only use input if this is believable. The regular expression for checking the email address is something like this (taken from ESAPI, enterprise security API):
^[A-Za-z0-9._%-] +@ [A-Za-z0-9.-]+\\.[a-zA-Z]{2,4}$
Demento
source share