ohdang888 Posted March 1, 2008 Share Posted March 1, 2008 how do i validate an email address?????/... like... make sure there is an @ and a .com, or.net, etc. i tried the code below but it didn;t work. if(!validate_email_address($email)){ Quote Link to comment Share on other sites More sharing options...
Orio Posted March 1, 2008 Share Posted March 1, 2008 <?php function valid_email($email) { if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) return false; return true; } ?> Orio. Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted March 1, 2008 Author Share Posted March 1, 2008 How does the return true and return false work??? Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted March 1, 2008 Share Posted March 1, 2008 basically, the return false is at the end of the if. The whole if can be interpretted like this: IF the email IS NOT valid fail the test otherwise pass the test Returning false is just a way of letting the script know whether the test was a success or not. by returning false your letting it know that the email address it NOT valid so you can then echo "your email is not valid"; or whatever. its kinda hard to explain, but I hope you get the idea Regards ACE 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.