Toms Posted February 24, 2005 Report Share Posted February 24, 2005 (edited) Nu cilveecinjsh regjistreejas un samaitaa visu. Manaa DB tikko viena meitene regjistreejaas ar shitaau meilu: xxx@.tvnet.lv. Blja, man dusmas pilniigi, kljuudas peec punktinju nospiedusi. Pagaidam man ir shitaa: function IsValidMail($ssstr) { //atgriezh 1 ja mails valiids, 0 ja nee if(ereg("^.+@.+\\..+$", $ssstr)) return 1; else return 0; } Re kaa... Mosh kaadam ir labaaks skriptinjsh zinaams? aaa, runa iet arii par taadu kaa teiksim www.xxx@tvnet.lv Edited February 24, 2005 by Toms Link to comment Share on other sites More sharing options...
рпр Posted February 24, 2005 Report Share Posted February 24, 2005 tu veel vari paarbaudiit vai mx (mail exchange) domains eksitee (getmxrr), bet useri gan iisti nevar paarabudiit, var vairaak skatiities peec standartiem kaaadi charakteri var ietilpt loginaa un kaadi nee. Link to comment Share on other sites More sharing options...
bubu Posted February 24, 2005 Report Share Posted February 24, 2005 (edited) e-pasta adreses formāts ir diezgan sarežģīts. Bet vairumam gadījumu domāju vajadzētu derēt sekojošai fjai: function IsValidMail($ssstr) { //atgriezh 1 ja mails valiids, 0 ja nee return preg_match('~^[-\w\d._]+@([-\w\d]+\.)+\w+$~i', $ssstr); } Edited February 24, 2005 by bubu Link to comment Share on other sites More sharing options...
Lynx Posted February 24, 2005 Report Share Posted February 24, 2005 bubu, ar tavejo preg_matchu ir viena problema... Vinsh nestrada, saka ka nav pareizs emails, pat ja ir ievadits pareizs un + vel met error notici ara ka nepatik: Unknown modifier '$' Tavs iepriekshejais variants stradaja, pirms editeshanas, iznemot to, ka ja iavadija blabla@blabla.lv. - vinsh ari shadu pienema. Es pats šādi parbaudu emailu: $email = $_POST['email']; if(!empty($email)) { $pemail = preg_match('/^[a-z0-9&\'\.\-_\+]+@[a-z0-9\-]+\.([a-z0-9\-]+\.)*?[a-z]+$/is', $email); if($pemail == '0'){ msg('Ievadīts nepareizs emails!'); } } Link to comment Share on other sites More sharing options...
bubu Posted February 24, 2005 Report Share Posted February 24, 2005 Lynx: man tur drukas kļūda bija: ~ ar $ biju otrādi uzlicis, tagad salaboju. A par tavu kodu: Kāda jēga lietot a-z, ja ir \w vai 0-9, ja ir \d. Un šī daļa "[a-z0-9\-]+\.([a-z0-9\-]+\.)*?" tavā regexpā var tikt aizstāta ar vienkārši "([a-z0-9\-]+\.)+", pie tam, kāda jēga no *?, ja jau * nozīmē 0..n, tad pieliekot ? nemainās pilnīgi nekas! Link to comment Share on other sites More sharing options...
Lynx Posted February 24, 2005 Report Share Posted February 24, 2005 Nu jaa isti labi vel nemaku visas shitas lietas. Paldies par uzlaboto variantu :) Link to comment Share on other sites More sharing options...
Recommended Posts