mirstigais Posted May 23, 2011 Report Share Posted May 23, 2011 (edited) jau labu laiku mēģinu saprast kļūdu, bet nekā, googlē arī pētu, bet cik izskatās if (!preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $email)) {echo "Nav ievadīta reāla e-pasta adrese. Mēģini vēlreiz."; } else { šajā rindiņā nav kļūdas, bet kad noņemu tad viss aiziet, līdz ar to nesaprotu kur ir kļūda. Tādēļ varbūt kāds var pateikt kur kļūda? <? $name=$_POST['name']; $email=$_POST['email']; $feedback=$_POST['feedback']; $name=trim($name); $email=trim($email); $feedback=trim($feedback); if (!preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $email)) {echo "Nav ievadīta reāla e-pasta adrese. Mēģini vēlreiz."; } else { $toaddress = "epasts@epasts.lv"; $subject = "No Weblapas"; $mailcontent = "Vārds: ".$name."\n" ."E-pasts: ".$toaddress."\n" ."Komentārs: \n".$feedback."\n"; $fromaddress = $toaddress; mail($toaddress, $subject, $mailcontent, "From: $fromaddress"); ?> <html> <head> <title>E-pasts nosūtīts</title> </head> <body> <h1>E-pasts nosūtīts</h1> <p>Vēstule ar sekojošu saturu ir nosūtīta <? echo $toaddress; ?>:</p> <p><? echo nl2br($mailcontent); } ?> </p> </body> </html> Edited May 23, 2011 by mirstigais Quote Link to comment Share on other sites More sharing options...
Kemito Posted May 23, 2011 Report Share Posted May 23, 2011 Vecīt žļergu sūkt negribas kaut kā neerti, tapēc ieliec visu code tagos, vai arī iemet paste.php.lv vai arī NEKO!. Quote Link to comment Share on other sites More sharing options...
mirstigais Posted May 23, 2011 Author Report Share Posted May 23, 2011 http://paste.php.lv/a1ba6ba33d36f3a9c7da7933a08addbe?lang=php Quote Link to comment Share on other sites More sharing options...
daGrevis Posted May 23, 2011 Report Share Posted May 23, 2011 Mēģini... "/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" ...uz: '/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/' Redzi, tā kā tiek izmantotas dubultās pēdiņas interpretators domā, ka "\" ir kā "escape character". Quote Link to comment Share on other sites More sharing options...
mirstigais Posted May 23, 2011 Author Report Share Posted May 23, 2011 Tas pats, uzrāda, ka nepareizs epasts Quote Link to comment Share on other sites More sharing options...
Rincewind Posted May 23, 2011 Report Share Posted May 23, 2011 Un šādi? '/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/' Quote Link to comment Share on other sites More sharing options...
mirstigais Posted May 23, 2011 Author Report Share Posted May 23, 2011 strādā, tikai šoreiz vēstu sūta gan ja ir pareizs, gan ja nepareizs epasts Quote Link to comment Share on other sites More sharing options...
Rincewind Posted May 23, 2011 Report Share Posted May 23, 2011 Man sāk likties ka google interfeiss ir pārlieku sarežģīts. [a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])? \b[\w\.-]+@[\w\.-]+\.\w{2,4}\b ^(([a-zA-Z0-9\._-]+)@([a-zA-Z0-9-]+)\.([a-zA-Z]{2,4}))$ ^[\w\d\|~&\+\-/%=_!#\$\^{}`\+\?\*]([\w\d\|~&\+\-/%=_!#\$\^{}`\.\+\?\*]*[\w\d\|~&\+\-/%=_!#\$\^{}`\+\?\*])?(@)[\w\d]([\w\d\.]*[\w\d\.])?(com|se|org|nu|net)$ ^[a-z0-9]+(?:[-\._]?[a-z0-9]+)*@(?:[a-z0-9]+(?:-?[a-z0-9]+)*\.)+[a-z]+$ ^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)+)@(([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)){2,}\.([A-Za-z]){2,4}+$ ^(\w|\.|-)+?@(\w|-)+?\.\w{2,4}($|\.\w{2,4})$ ^(?:\\w+\(\.|-)+)*\\w+@(?:\\w+\(\.|-)+)*\\w+\\.\\w+$ [a-zA-Z0-9._-]+@[a-zA-Z0-9]+.[a-z]+(.[a-z]+)? \b[!#\$%&'\*\+\-/=\?\^_`{\|}~a-zA-Z0-9][!#\$%&'\*\+\-/=\?\^_`{\|}~a-zA-Z0-9\.]*[!#\$%&'\*\+\-/=\?\^_`{\|}~a-zA-Z0-9]@[a-zA-Z0-9\-][a-zA-Z0-9\-\.]+[a-zA-Z0-9\-]\b Quote Link to comment Share on other sites More sharing options...
mirstigais Posted May 23, 2011 Author Report Share Posted May 23, 2011 vienkārši šis bija 3 veids kuru testēju un kurš negāja, tādēļ iedomājos varbūt tomēr kautkur citur kļūda, bet redz nē jo trešais variants aizgāja. Paldies! Quote Link to comment Share on other sites More sharing options...
e-remit Posted May 24, 2011 Report Share Posted May 24, 2011 Nav sanācis pašam ar šiem darboties, bet var izmantot PHP iebūvētās funkcijas filter_var($email, FILTER_VALIDATE_EMAIL) Quote Link to comment Share on other sites More sharing options...
Zefirs Posted May 24, 2011 Report Share Posted May 24, 2011 Pēdējo reiz kad meklēju labu epasta filtru es uzdūros kādam rakstam kur tika apkopoti dažādi pasaules standarti filtrējot pareizās epasta adrese, ka arī to uzlabojumi. Tā kā e-pasta adreses var būt ar ip adresēm un vēl dažnedažākajiem veidiem, tad īstenībā lai visus veidus atrastu nepieciešams nežēlīgi garš koda gabals, kurš diemžēl arī pat tad nespēja atfiltrēt visas reālās adreses. Vai maz eksistē tāds universāls filtrs? Quote Link to comment Share on other sites More sharing options...
marcis Posted May 24, 2011 Report Share Posted May 24, 2011 http://www.w3.org/Protocols/rfc822/ $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; $pair = '\\x5c[\\x00-\\x7f]'; $domain_literal = "\\x5b($dtext|$pair)*\\x5d"; $quoted_string = "\\x22($qtext|$pair)*\\x22"; $sub_domain = "($atom|$domain_literal)"; $word = "($atom|$quoted_string)"; $domain = "$sub_domain(\\x2e$sub_domain)*"; $local_part = "$word(\\x2e$word)*"; $expression = "/^$local_part\\x40$domain$/D"; return (bool)preg_match($expression, (string)$email); Quote Link to comment Share on other sites More sharing options...
mixis Posted May 25, 2011 Report Share Posted May 25, 2011 Nav sanācis pašam ar šiem darboties, bet var izmantot PHP iebūvētās funkcijas filter_var($email, FILTER_VALIDATE_EMAIL) Pēdējā laikā ar šo variantu lietoju. Strādā bez problēmām. 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.