tcorbeil Posted April 4, 2007 Share Posted April 4, 2007 And another.. I use: if (!@file_get_contents($weblink)){ @header("Location: ".$_SERVER['HTTP_REFERER']); } where $weblink is equal to a website.. this is to validate a weblink.. What would I use to validate an email address? Thanks. Quote Link to comment Share on other sites More sharing options...
per1os Posted April 4, 2007 Share Posted April 4, 2007 www.php.net/ereg view the user comments you will find a validation function there. Quote Link to comment Share on other sites More sharing options...
tcorbeil Posted April 5, 2007 Author Share Posted April 5, 2007 Found this code on the site: On a small note to email checking: Recently it is possible to register domains like www.k�che.de This would also mean that the IsEMail() function from "php at easy2sync dot com" would report an email address like "contact@k�che.de" as false. To correct this, use the function below: function IsEMail($e) { if(eregi("^[a-zA-Z0-9]+[_a-zA-Z0-9-]* (\.[_a-z0-9-]+)*@[a-z������0-9]+ (-[a-z������0-9]+)*(\.[a-z������0-9-]+)* (\.[a-z]{2,4})$", $e)) { return TRUE; } return FALSE; } not sure if I'm implementing it correctly.. do i call as such? $Email = dsdfsf@sdsgjg.com IsEMail ($Email); out of the function above, how would I come out with a marker variable such as $verify = It's good or $verify= It's bad... Can anyone clarify? Thanks. Quote Link to comment Share on other sites More sharing options...
jitesh Posted April 5, 2007 Share Posted April 5, 2007 Use This reg exp if(preg_match("/^[a-zA-Z_]+(\w+)*((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/i",$email){ echo "valid email"; } Quote Link to comment Share on other sites More sharing options...
tcorbeil Posted April 5, 2007 Author Share Posted April 5, 2007 I have modified the code to this: if(eregi("/^[a-zA-Z_]+(\w+)*((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/i", $Email)) { return TRUE; echo "1";} I don't see the echo come up even though I know it is valid.. any other suggestions? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 5, 2007 Share Posted April 5, 2007 Once the return statement is executed, the function stops. Put the echo before the return. Ken Quote Link to comment Share on other sites More sharing options...
tcorbeil Posted April 5, 2007 Author Share Posted April 5, 2007 Hi Ken. I did exactly what you mentioned and it still does not echo.. I even tried removing the return command period.. Any other ideas? Quote Link to comment Share on other sites More sharing options...
jitesh Posted April 5, 2007 Share Posted April 5, 2007 ........... ........... .......... function isvalidemail($email){ if(preg_match("/^[a-zA-Z_]+(\w+)*((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/i",$email) return true; else return false; } if(isvalidemail($email)){ echo "This is valid email"; } 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.