having trouble with eregi function

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
daveheinzel
Forum Newbie
Posts: 8
Joined: Tue Dec 02, 2003 10:47 pm

having trouble with eregi function

Post by daveheinzel »

I can't seem to get this thing to work! I'm trying to validate an email form to only contain a regular email address. But it keeps coming back 'nope', which as you'll see below means that the email address is invalid. The test email variable has been set to a common type of email address, so if it works correctly, it should return a 'successful' statement.

The code is a simplified form I have been practicing with, not the full form. Is there a syntax problem? I can't find one.

Code: Select all

<?php

$sal = "testmail@aol.com";

if (eregi ("^[[]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", $sal)) {

echo '<p>successful</p>';

} else {

echo '<p>nope</p>';

}

?>
Thanks,
Dave
daveheinzel
Forum Newbie
Posts: 8
Joined: Tue Dec 02, 2003 10:47 pm

got it

Post by daveheinzel »

Sorry guys, I found the answer in a post on this forum. Wouldn't have posted if I found it first!

For those interested, the correct code can be found at:

http://www.zend.com/tips/tips.php?id=8&single=1

-Dave
Post Reply