email validator


SUBMITTED BY: Guest

DATE: June 11, 2013, 9:25 p.m.

FORMAT: PHP

SIZE: 618 Bytes

HITS: 1225

  1. <?php
  2. $email = "email.com";
  3. $email = preg_match("/[a-zA-Z@_-]/", $email);
  4. try
  5. {
  6. if (!$email)
  7. {
  8. throw new Exception("Email is not valid!");
  9. } else
  10. {
  11. return 1;
  12. }
  13. }
  14. catch (exception $e)
  15. {
  16. echo "Error Message: <font color='red'>" . $e->getMessage() . "</font><br />";
  17. echo "The error is on line: <font color='red'>" . $e->getLine() .
  18. "</font><br />";
  19. echo "The file the error is in: <font color='red'>" . $e->getFile() .
  20. "</font><br />";
  21. }
  22. ?>

comments powered by Disqus