Hi guys!
I'm trying to make a PHP mailer and I have a little problem with the eregi() function.
This is the code:

if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $senders_email))
	{
	$error = "1";
	$info_error .= $lang_invalidemail . "<br>"; 
	}

and it gives me this error:
Deprecated: Function eregi() is deprecated in D:\wamp\www...
I've tried with !preg_match() but it didn't worked too.

Also I have this error: Notice: Undefined variable: info_error in...
for this code:

if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$", $senders_email))
	{
	$error = "1";
	The same code but the error is here>>$info_error .= $lang_invalidemail . "<br>"; 
	}

Thanks in advance!

What doesn't work about preg_match?
Don't worry about notices. In this case, it is only a problem if magic quotes are on. You could put $info_error=''; somewhere above that line.

It worked like this:

if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,6}$/i", $senders_email))
	{
	$error = "1";
	$info_error='';
	$info_error .= $lang_invalidemail . "<br>"; 
	}

I've forgot to add / in front of ^ in the beginning.
Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.