jr_cumbo Posted July 4, 2008 Share Posted July 4, 2008 Hi, Just wondering if someone can see something wrong with this code. <?php $email=($_POST['email']); if (isset($_POST['submit']) and $email !== '') { if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)); { echo "<font color=red><b><---[ERROR]:Please enter a vaild E-Mail Address</font>"; } } if (isset($_POST['submit'])) { if (($_POST['email']) == '') { echo "<font color=red><b><---[ERROR]:</b>Please enter a Email Address</font>"; } } ?> It will not validate the e-mail correctly. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/113215-solved-e-mail-validation/ Share on other sites More sharing options...
br0ken Posted July 4, 2008 Share Posted July 4, 2008 Use this function to validate email addresses instead! <? function validEmail($email) { if (filter_var($email, FILTER_VALIDATE_EMAIL)) return true; else return false; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/113215-solved-e-mail-validation/#findComment-581644 Share on other sites More sharing options...
jr_cumbo Posted July 4, 2008 Author Share Posted July 4, 2008 Excellent that's a yeps better way of doing it.. It worked!! Thanks Man:) Quote Link to comment https://forums.phpfreaks.com/topic/113215-solved-e-mail-validation/#findComment-581646 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.