Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Sprawdzanie maila
-Kffiatek-
post
Post #1





Goście







szukam osoby która napisze mi skrypt który sprawdza czy adres e-mail został poprawnie wpisany.... jest mi to bardzo potrzebne a w php prawie nic nie umiem... :/
Go to the top of the page
+Quote Post
Kshyhoo
post
Post #2





Grupa: Opiekunowie
Postów: 3 855
Pomógł: 317
Dołączył: 4.01.2005
Skąd: że




Średnio 7x w tygodniu się o to pytają, więc można z łatwością poszukać...
  1. <?php
  2. function verifyEmail($email) {
  3. $wholeexp = '/^(.+?)@(([a-z0-9.-]+?).[a-z]{2,5})$/i';
  4. $userexp = "/^[a-z0-9~!#$%&()-_+=[];:'",./]+$/i";
  5. if (preg_match($wholeexp, $email, $regs)) {
  6. $username = $regs[1];
  7. $host = $regs[2];
  8. if (checkdnsrr($host, MX)) {
  9. if (preg_match($userexp, $username)) {
  10. return true;
  11. } else {
  12. return false;
  13. }
  14. } else {
  15. return false;
  16. }
  17. } else {
  18. return false;
  19. }
  20. }
  21. ?>

  1. <?php
  2. function checkMail($email) {
  3. return preg_match('/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/', $email);
  4. }
  5. if (checkMail('user@host.pl'))
  6. echo 'Adres e-mail jest poprawny.'; else
  7. echo 'Niepoprawny format adresu e-mail.';
  8. ?>

  1. <?php
  2. function PoprawnyEmail($adres)
  3. {
  4.  return (preg_match ("/(@.*@)|(..)|(@.)|(.@)|(^.)/", $adres) ||
  5.  preg_match("/^.+@([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,3}|[0-9]{1,3})(]?)$/",$adres)));
  6. }
  7. ?>
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 18.09.2025 - 04:27