-2
elseif(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $user_email)) 

Even i tried with preg_match in this too i am getting

Warning:

preg_match() [function.preg-match]: No ending delimiter '^' found in C:\wamp\www\Saravanan\jQuery\jQuery - Samples\sign_and_login_using_jquery_ajax_and_php\sign_and_login_using_jquery_ajax_and_php\vpb_save_details.php on line 29
Call Stack
Marc
  • 3,683
  • 8
  • 34
  • 48
  • I believe the error message is pretty clear. As is [the manual](http://php.net/manual/en/function.preg-match.php). – PeeHaa Apr 09 '13 at 07:24
  • Error messages try hard not to lie. And you're using an [obsolete function](http://php.net/eregi) – Touki Apr 09 '13 at 07:24
  • 1
    Regular expression delimiters: `/regex/` – elclanrs Apr 09 '13 at 07:25
  • And even if you didn't get that error, that still wouldn't be the way to [validate an emailaddress](http://stackoverflow.com/questions/12026842/how-to-validate-an-email-address-in-php/12026863#12026863) – PeeHaa Apr 09 '13 at 07:26
  • POSIX regex are deprecated in PHP 5.. so don't use ereg,eregi etc.. also if ur using preg_match.. enclosed it in delimmeter "/regex/" as in comment by @elclanrs .. – Dinesh Apr 09 '13 at 07:31
  • delimiter will work ? – user2219660 Apr 09 '13 at 08:19

2 Answers2

2

Use this one:

if(!filter_var($user_email,FILTER_VALIDATE_EMAIL))
Rashad
  • 1,344
  • 2
  • 17
  • 33
1

and if the var comes from POST:

if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL))
MGE
  • 803
  • 2
  • 12
  • 22
  • It should be mentioned that there's a slight difference between failing the filter and the variable not being posted though. – Ja͢ck Apr 09 '13 at 07:29