Skip to content

Instantly share code, notes, and snippets.

@Stichoza
Last active October 12, 2015 01:48
Show Gist options
  • Save Stichoza/3952650 to your computer and use it in GitHub Desktop.
Save Stichoza/3952650 to your computer and use it in GitHub Desktop.
PHP E-mail and Username Validation
<?php
function is_valid_email($s) {
return preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', $s);
}
function is_valid_username($s) {
return preg_match('/^[A-Za-z0-9-_]+$/', $s);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment