email validation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tiresome
Forum Newbie
Posts: 16
Joined: Sun Apr 18, 2004 9:45 am

email validation

Post by tiresome »

Code: Select all

<?php

if ( !checkString( $email) || !eregi( "^[A-Za-z0-9\_-]+@[A-Za-z0-9\_-]+.[A-Za-z0-9\_-]+.*", $email)) {
    echo "You have entered an <b>invalid email</b>.<br> Please go back and try again.";
    exit;
  }

?>
The above code works to some extent. If the user does not input an '@' then the above error message is displayed but the 'dot' part after that does not work. I want the user to input an email address in the form xxx@xxx.com and I think I have written eregi part in that format.

I have no idea why the '@' sign works while the 'dot' after that doesn't! Any suggestions as to why this might be the case? Any help would be greatly appreaciated
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

answer in your other thread.
Post Reply