Is valid email
#1

Hi,

How to check for valid email, i want to check specific player can write any name xxxxxx/ but website from where create email i want specify, like gmail, yahoo, inbox and what i want
Reply
#2

No body give me function

I found at least:

Code:
stock IsCorrectMail(mail[])
{
	new len = strlen(mail), bool:find[2], w;
 	if(!(6 < len < 129)) return false;
  	for(new l; l < len; l++)
  	{
   		if(mail[l] == '.') find[0] = true;
     	if(mail[l] == '@')
      	{
       		if(find[1]) return false;
         	find[1] = true;
          	w = l;
           	if(w > 64) return false;
       	}
        if(!(mail[l] >= 'A' && mail[l] <= 'Z' || mail[l] >= 'a' && mail[l] <= 'z' || mail[l] >= '0' && mail[l] <= '9' || mail[l] == '.' || mail[l] == '-' || mail[l] == '_' || mail[l] == '@')) return false;
   	}
    if(len - w > 65) return false;
    if(!find[0] || !find[1]) return false;
    return true;
}
But how to upgrade this function how i mention check i want allow just from @gmail.com, @yahoo.com just some what i specified.
Reply
#3

Loop, find @, break loop, compare string starting at the index after @ with the ones you specify.

You could also use strfind to get the index.
Reply
#4

Can you remake this function for me?
Reply
#5

What do I get?
Reply
#6

respect from me this too will be usefull for others users
Reply
#7

Show some respect, and say "thank you mighty dad" then!

PHP Code:
main()
{
    print((
IsValidEmail("@hotmail.com")) ? ("1. Yes") : ("1. No"));
    print((
IsValidEmail("spiderman@outlook.com")) ? ("2. Yes") : ("2. No"));
    print((
IsValidEmail("superman@hotmail.com")) ? ("3. Yes") : ("3. No"));
    print((
IsValidEmail("batman@gmail.com")) ? ("4. Yes") : ("4. No"));
}
IsValidEmail(const email[])
{
    new 
at_pos strfind(email"@"true) + 1;
    if(
email[0] == '@' || at_pos == -1)
    {
        return 
false;
    }
    static const 
providers[][] =
    {
        
"hotmail.com",
        
"gmail.com"
    
};
    for(new 
0sizeof(providers); ++)
    {
        if(!
strcmp(email[at_pos], providers[i], true))
        {
            return 
true;
        }
    }
    return 
false;

Reply
#8

if(!strcmp(email[at_pos], providers[i], true))
{

This take not just email[at_pos] only @ letter?
Reply
#9

Everything after @.

Show some respect, and say "thank you mighty dad"!
Reply
#10

I'm sure Vinces example worked a little bit... Just a little bit...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)