dAivEd Posted February 1, 2010 Report Share Posted February 1, 2010 if(!preg_match('/^[A-Za-z0-9]*$/i', $_POST['email'])) { Palidziet ludzu atljaut "@" simbolu preg_match funkcija, skatijos manualus, nekas nesanak ;( Quote Link to comment Share on other sites More sharing options...
2easy Posted February 1, 2010 Report Share Posted February 1, 2010 if(!preg_match('/^[a-z0-9@]*$/i', $_POST['email'])) { Quote Link to comment Share on other sites More sharing options...
Kaklz Posted February 1, 2010 Report Share Posted February 1, 2010 e-pastos ir atļauts arī, piemēram, punkts. Ar šādu regulāro izteiksmi tev derīgs e-pasts būs arī teksts "something@", kas ne tuvu nav līdzīgs korektam e-pastam. Priekš e-pasta validācijas iesaku vienkārši paskatīties php.net dokumentācijas komentāros pie šīs pašas preg_match funkcijas. Quote Link to comment Share on other sites More sharing options...
2easy Posted February 1, 2010 Report Share Posted February 1, 2010 (edited) me agree 2 Kaklz es tik atbildēju uz tiešo jautājumu ;) pats lietoju šādu email patternu define('PN_EMAIL', '/^[a-z0-9_.-]+@[a-z0-9_.-]+\.[a-z]{2,3}$/i'); PN - pattern ("mikro nosaukums" manā stilā :D:D:D) Edited February 1, 2010 by 2easy Quote Link to comment Share on other sites More sharing options...
Kaklz Posted February 1, 2010 Report Share Posted February 1, 2010 2easy, var_dump(preg_match(PN_EMAIL, 'zz@zz.info')); Quote Link to comment Share on other sites More sharing options...
2easy Posted February 1, 2010 Report Share Posted February 1, 2010 2easy, var_dump(preg_match(PN_EMAIL, 'zz@zz.info')); paldies, Kaklz update define('PN_EMAIL', '/^[a-z0-9_.-]+@[a-z0-9_.-]+\.[a-z]{2,4}$/i'); Quote Link to comment Share on other sites More sharing options...
Kaklz Posted February 1, 2010 Report Share Posted February 1, 2010 labāk vienkārši paskaties tajos php.net komentāros: var_dump(preg_match(PN_EMAIL, '.@..com')); Quote Link to comment Share on other sites More sharing options...
rpr Posted February 1, 2010 Report Share Posted February 1, 2010 no shii pasha foruma kaads cilveeks reiz ieposteeja sho funkciju, neeesmu pats veel izmantojis, bet domaaju, ka shis ir labaakais variants. http://fr.php.net/manual/en/function.filter-var.php Quote Link to comment Share on other sites More sharing options...
2easy Posted February 1, 2010 Report Share Posted February 1, 2010 labāk vienkārši paskaties tajos php.net komentāros: var_dump(preg_match(PN_EMAIL, '.@..com')); tas, kurš gribēs iepostot fake email, to vnm varēs izdarīt. pat ja čekotu, vai tāds email akounts vsp eksistē, var gadīties, ka uz to brīdi mail server ir off Quote Link to comment Share on other sites More sharing options...
eT` Posted February 1, 2010 Report Share Posted February 1, 2010 pats izmantoju šo: function valid_mail($email) { return preg_match('/^[\w.-]+@([\w.-]+\.)+[a-z]{2,6}$/is', $email); } valid_mail($_POST["mail"]); Quote Link to comment Share on other sites More sharing options...
2easy Posted February 1, 2010 Report Share Posted February 1, 2010 (edited) nju tas jau gandrīz tas pats vien ir ;) btw ir arī garāki piemēri par .com .info ??? vnk tev tur ir {2,6} Edited February 1, 2010 by 2easy Quote Link to comment Share on other sites More sharing options...
eT` Posted February 1, 2010 Report Share Posted February 1, 2010 ja arī ir tad nezinu tādus :) Quote Link to comment Share on other sites More sharing options...
2easy Posted February 1, 2010 Report Share Posted February 1, 2010 ohh, tad labi, es jau nodomāju, ka vēl vienu update vajadzēs ;) Quote Link to comment Share on other sites More sharing options...
2easy Posted February 1, 2010 Report Share Posted February 1, 2010 (edited) oops, tomēr vajadzēs :D tie 6x chari ir for .museum un .travel http://iana.org/domains/root/db kr4 tur ar to skaitu nav vērts cīnīties. vnk + ftw :)) "for future compatiblity" tāpēc final update (i hope) define('PN_EMAIL', '/^[a-z0-9_.-]+@[a-z0-9_.-]+\.[a-z]+$/i'); turklāt filter_var() arī to atļauj ;) var_dump(filter_var('asdf@asdf.asdfasdfasdfasdfasdf', FILTER_VALIDATE_EMAIL, FILTER_FLAG_SCHEME_REQUIRED)); btw, šajā piemērā var labi redzēt, cik php ir consistent naming var_dump() filter_var() brīnišķīgi! :D:D:D Edited February 1, 2010 by 2easy Quote Link to comment Share on other sites More sharing options...
ohmygod Posted February 1, 2010 Report Share Posted February 1, 2010 ja pa tiešām ir ļooti svarīgi čekot emaila pareizību - der pārbaudīt vai domēnam eksistē MX ieraksti! http://lv.php.net/manual/en/function.getmxrr.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.