Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP email validation function [duplicate]

Tags:

php

Is there an equivalent to mysql_real_escape_string() for email injection? I have a form where the user submits their email. I am afraid that someone could insert a comma separated list of emails and use my site for spamming.

like image 851
Brian Avatar asked Jan 27 '10 11:01

Brian


1 Answers

You can use filter_var to validate the e-mail address:

if (!filter_var($address, FILTER_VALIDATE_EMAIL)) {
    // invalid e-mail address
}
like image 71
Gumbo Avatar answered Sep 20 '22 11:09

Gumbo