Page 1 of 1

having trouble with eregi function

Posted: Fri Dec 05, 2003 1:25 pm
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

got it

Posted: Fri Dec 05, 2003 1:47 pm
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