One line validate email. PHP >= 5.2

/* * Let's say your receiving email from a form post * * This function will return BOOL(FALSE) or the string with the email. * * -- NOTE: THIS WILL NOT CHECK TO SEE IF EMAIL EXISTS, * -------- ONLY THAT THE FORMATTING IS CORRECT. YOU WILL * -------- STILL NEED TO ESCAPE VALUE BEFORE PUTTING IN A DB. */ if(!filter_var($_POST['email_address'], FILTER_VALIDATE_EMAIL)) { echo 'Invalid email address! Now go do something.'; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.