Is valid email - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Is valid email (
/showthread.php?tid=626317)
Is valid email -
MerryDeer - 13.01.2017
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
Re: Is valid email -
MerryDeer - 13.01.2017
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.
Re: Is valid email -
SickAttack - 13.01.2017
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.
Re: Is valid email -
MerryDeer - 13.01.2017
Can you remake this function for me?
Re: Is valid email -
SickAttack - 13.01.2017
What do I get?
Re: Is valid email -
MerryDeer - 13.01.2017
respect from me
this too will be usefull for others users
Re: Is valid email -
SickAttack - 13.01.2017
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 i = 0; i < sizeof(providers); i ++)
{
if(!strcmp(email[at_pos], providers[i], true))
{
return true;
}
}
return false;
}
Re: Is valid email -
MerryDeer - 13.01.2017
if(!strcmp(email[at_pos], providers[i], true))
{
This take not just email[at_pos] only @ letter?
Re: Is valid email -
SickAttack - 13.01.2017
Everything after @.
Show some respect, and say "thank you mighty dad"!
Re: Is valid email -
Sew_Sumi - 13.01.2017
I'm sure Vinces example worked a little bit... Just a little bit...