We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19596
    • 5 Posts
    When i try to update a web user, I get this error:

    Error:	Function ereg() is deprecated	 
      Error type/ Nr.:	 - 8192	 
      File:	E:\xampp\htdocs\assets\snippets\weblogin\webeditprofile.inc.php	 
      Line:	42	 
      Line 42 source:	 $output = webLoginAlert("Password typed is mismatched").$tpl;


    I found out that ereg must be replaced with preg_match, but can’t find out how. Here’s the code:

    if($_POST['email']=='' || !ereg("^[-!#$%&'*+./0-9=?A-Z^_`a-z{|}~]+", $_POST['email'])){
    		$output = webLoginAlert("E-mail address doesn't seem to be valid!").$tpl;
    		return;
    	}


    The ereg() must be replaced with preg_match(). How?

    Thanks
      • 19596
      • 5 Posts
      I messed with the code: this is the original which needs to be modified!
      if($_POST['email']=='' || !ereg("^[-!#$%&'*+./0-9=?A-Z^_`a-z{|}~]+", $_POST['email'])){
      		$output = webLoginAlert("E-mail address doesn't seem to be valid!").$tpl;
      		return; 
      }

      (code is now the same as first post!)
      (didnt know how to modify. sorry for doublepost)

        • 4310
        • 2,310 Posts
        Untested, but try :
        if(!preg_match("/^[-!#$%&'*+./0-9=?A-Z^_`a-z{|}~]+/i", $str)){
        		$output = webLoginAlert("E-mail address doesn't seem to be valid!").$tpl;
        		return; 
        }
        
          • 19596
          • 5 Posts
          Doesnt work:

          PHP error debug
            Error:	preg_match() [function.preg-match]: Unknown modifier '0'	 
            Error type/ Nr.:	Warning - 2	 
            File:	G:\xampp\htdocs\assets\snippets\weblogin\webeditprofile.inc.php	 
            Line:	42	 
            Line 42 source:	 $output = webLoginAlert("Password typed is mismatched").$tpl;
            • 4310
            • 2,310 Posts
            Sorry, a bit of careless copying & pasting!
            if($_POST['email']=='' || !preg_match("/^[-!#$%&'*+./0-9=?A-Z^_`a-z{|}~]+/i", $_POST['email'])){
            		$output = webLoginAlert("E-mail address doesn't seem to be valid!").$tpl;
            		return; 
            }
              • 19596
              • 5 Posts
              Thanks for the help btw,
              But now i get this error:

              PHP error debug
                Error:	preg_match() [function.preg-match]: Unknown modifier '0'	 
                Error type/ Nr.:	Warning - 2	 
                File:	G:\xampp\htdocs\assets\snippets\weblogin\webeditprofile.inc.php	 
                Line:	42	 
                Line 42 source:	 $output = webLoginAlert("Password typed is mismatched").$tpl;
                • 4310
                • 2,310 Posts
                Another try :
                if($_POST['email']=='' || !preg_match("/^[-!#$%&'*+.0-9=?A-Z^_`a-z{|}~]+/i", $_POST['email'])){
                		$output = webLoginAlert("E-mail address doesn't seem to be valid!").$tpl;
                		return; 
                }
                  • 19596
                  • 5 Posts
                  Quote from: bunk58 at Jan 19, 2010, 04:54 AM

                  Another try :
                  if($_POST['email']=='' || !preg_match("/^[-!#$%&'*+.0-9=?A-Z^_`a-z{|}~]+/i", $_POST['email'])){
                  		$output = webLoginAlert("E-mail address doesn't seem to be valid!").$tpl;
                  		return; 
                  }

                  Thank you very much for helping met out. This works like a charm smiley
                  I see the slash before 0 was the problem
                    • 4310
                    • 2,310 Posts
                    Yes the / was a problem, it might work with a / like this :
                    if($_POST['email']=='' || !preg_match("/^[-!#$%&'*+.\/\0-9=?A-Z^_`a-z{|}~]+/i", $_POST['email'])){
                    		$output = webLoginAlert("E-mail address doesn't seem to be valid!").$tpl;
                    		return; 
                    }