because i didn't know how to make it work, but i just tried again and it's working. thank you for the advice.

but i would be really glad if i could fix my first "problem". i just want to see where is the mistake. thank you !

and i have another question. to check if the user entered his name, it's ok to check like this ? i mean if it's correct to check with strlen.

  function validateName($name){
		//if it's NOT valid
		if(strlen($name) > 3)
			return true;
		//if it's valid
		else
			return false;
	}

    You were already told what your first problem was. You were using ereg() instead of preg().

      And you didn't answer my first question ("How is it 'not working'?"). And while you're putting together a useful reply (with error messages and so on), try and see if studying the symptoms (the error messages and so on) give you any information about the problem (that's what error messages are for).

        Bonesnap, i changed ereg with preg_match and it's not working either.

        Weedpacket, for example this code is working:

        function validateEmail($email){
        	$pattern = "~\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}\b~i";
                return preg_match($pattern,$email);
            }  

        and if i change

        ~\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}\b~i

        with

        /^(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){65,}@)(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22))(?:\.(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\]))$/

        it's not working anymore. i don't have any error in dreamweaver, but i when i try to send my form, it says that john@yahoo.com it's an invalid email address. i hope you understand. thank you.

          You have also been told to use the filter_var() function instead, then you wouldn't have to deal with complex and often incorrect regular expressions.

            That's not how filter_var() is used. Read the manual and you will see that filter_var() does not take a regular expression as an argument.

              The site you linked also says that

              The expression with the best score is currently the one used by PHP's filter_var()

              So why bother with trying to get a regex working when the built in function already ranks the highest?

                greentrancer wrote:

                i don't have any error in dreamweaver, but i when i try to send my form, it says that john@yahoo.com it's an invalid email address. i hope you understand. thank you.

                It works for me. Mind you, I did put it in single quotes so that PHP wouldn't try to parse all the escape sequences and such (if you have [font=monospace]"/\x2f/"[/font], the PCRE parser is given [font=monospace]///[/font], which is broken).

                If I use double quotes I get warning messages about an invalid pattern. You do have error reporting turned on, don't you?

                  Derokorian, i just want to see where is the problem, why that regex is not working. it's working perfectly in jquery, although it's made for php.

                  Weedpacket, i tried just now with single quotes and it's working! though, i don't understand what do you mean with "wouldn't try to parse all the escape sequences and such (if you have "/\x2f/", the PCRE parser is given ///, which is broken). " because i am a beginner, thank you for spotting the error!!!
                  what do you mean with error reporting turned on ? sometimes when i'm writting the php code wrong, i receive a message on the left of the screen that i have an error on that line. are you speaking about this? thank you again!

                  edit: also, could you advise me on this one http://www.phpbuilder.com/board/showpost.php?p=10997551&postcount=8 ? thanks!!

                    greentrancer;10997808 wrote:

                    i don't understand what do you mean with "wouldn't try to parse all the escape sequences and such (if you have "/\x2f/", the PCRE parser is given ///, which is broken). "

                    Simple example:

                    echo '/\x2f/'; // output: /\x2f/
                    echo "/\x2f/"; // output: ///

                    Note that the first string is a valid REGEXP pattern, while the second one obviously is not.

                    greentrancer;10997808 wrote:

                    what do you mean with error reporting turned on ?

                    He means setting display_errors to On and error_reporting set to E_ALL (or better).

                      Write a Reply...