JU1CY
JU1CY

Reputation: 123

php mail eregi and preg_match error

I have php mail form for users and after upgrade got this error:

Deprecated: Function eregi() is deprecated

Here is code line which is checking email for valid:

if(trim($_POST['COTB_05']) == '') {$hasError = true;} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['COTB_05']))) {$hasError = true;} else {$COTB_05 = trim($_POST['COTB_05']);}

Tried to change eregi to preg_match:

if(trim($_POST['COTB_05']) == '') {$hasError = true;} else if (!preg_match("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['COTB_05']))) {$hasError = true;} else {$COTB_05 = trim($_POST['COTB_05']);}

but got another error:

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in W:\domains\localhost\content\email_cotb.php on line 4

FIX: Forgot to use /i

!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$/i"

So it's not case sensetive :)

Upvotes: 0

Views: 20

Answers (0)

Related Questions