-1

I'm using this php code. but it's giving error

Deprecated: Function eregi() is deprecated in C:\xampp\htdocs\fuel\emailcheck.php on line 7

<?
include_once("mastersecure.php");
$emailcheck=$_POST["member_name"];
function isValidEmail($email){
      $pattern = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$";

      if (eregi($pattern, $email)){
         return true;
      }
      else {
         return false;
      }   
   }
  if (!isValidEmail($_POST['member_name'])){
                echo "The email is invalid!";
            }
    else
     {
       $query="select email from fuel where email='$_POST[member_name]'";
       $res=mysql_query($query);
       $rowcount=mysql_num_rows($res);
       if($rowcount!=0)
       { echo "This mail is already exits"; }
     }      
?>

Any solution for this?

hakre
  • 193,403
  • 52
  • 435
  • 836
Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852
  • possible duplicate of [how to solve the ereg function deprecated error](http://stackoverflow.com/questions/4825205/how-to-solve-the-ereg-function-deprecated-error) – Gordon Feb 27 '11 at 10:31
  • possible duplicate of [PHP - Email Validation](http://stackoverflow.com/questions/4906608/php-email-validation) – Gordon Feb 27 '11 at 10:33
  • *(related)* [Does FILTER_VALIDATE_EMAIL make a string safe for insertion in database?](http://stackoverflow.com/questions/4154685/does-filter-validate-email-make-a-string-safe-for-insertion-in-database) – Gordon Feb 27 '11 at 10:35
  • *(related)* [XKCD SQL injection - please explain](http://stackoverflow.com/questions/332365/xkcd-sql-injection-please-explain) – Gordon Feb 27 '11 at 10:36

1 Answers1

0

use

<?
include_once("mastersecure.php");
$emailcheck=$_POST["member_name"];
function isValidEmail($email){
      $pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i";

      if (preg_match($pattern, $email)){
         return true;
      }
      else {
         return false;
      }   
   }
  if (!isValidEmail($_POST['member_name'])){
                echo "The email is invalid!";
            }
    else
     {
       $query="select email from fuel where email='$_POST[member_name]'";
       $res=mysql_query($query);
       $rowcount=mysql_num_rows($res);
       if($rowcount!=0)
       { echo "This mail is already exits"; }
     }      
?>

http://php.net/manual/en/function.preg-match.php

http://php.net/manual/en/function.eregi.php

delphist
  • 4,409
  • 1
  • 22
  • 22