gum spam detection / email validation

Started on the old forum in April 2011 · view the original in the archive · old links redirect here

6 replies · 1,324 views · started 15 years ago · 1 min read

4 participants
GumSlone Administrator Principal · 1,690 posts #1

detect spam in a string, this function will return true if spam is detected or false if there is no spam:

function gum_spam_check($str)
{
	$arr = array('.co','.net','www.','http:','wen.','mobisex','.in','.ru','.tk'); 
	foreach($arr as &$value)
	{
		if(stristr($str, $value))
		{
			return true;
			break;
		}
	}
	return false;
}

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

CuteAmit Junior · 35 posts #4

gum spam detection

GumSlone

Nice Coding......

Iam going to change it to another important function. this function will return true if email id is valid or false if there email is invalid.

<?php

function email_check($email) {

$valid = array('@','gmail.com','yahoo.com','msn.com');

foreach($valid as $var) {

if(stristr($email,$var)) {

return true;
break;

}

else

return false;

}
}
?>

For Latest Technology Tips & Tricks Click Here

GumSlone Administrator Principal · 1,690 posts #5

email validation / email check

CuteAmit wrote: GumSlone

Nice Coding......

Iam going to change it to another important function. this function will return true if email id is valid or false if there email is invalid.

<?php

function email_check($email) {

$valid = array('@','gmail.com','yahoo.com','msn.com');

foreach($valid as $var) {

if(stristr($email,$var)) {

return true;
break;

}

else

return false;

}
}
?>

your function doesnt work it will return true if you check any work which contains @, also there are better ways to check if the email is valid.

to validate email you can use something like this:

function check_email($str)
{
if( preg_match('/^([a-z0-9])(([-a-z0-9._])*([a-z0-9]))*
 \@([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])([a-z0-9])+)*$/i'
,$str))
return true;
else return false;
}

or i found at php.net another way, which is:

function check_email($str)
{
if(!filter_var($str, FILTER_VALIDATE_EMAIL)) {
     return false;
 } else {
     return true;
 }

}

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

CuteAmit Junior · 35 posts #6

GumSlone wrote: or i found at php.net another way, which is:

function check_email($str)
{
if(!filter_var($str, FILTER_VALIDATE_EMAIL)) {
     return false;
 } else {
     return true;
 }

}

Nice & pretty function to validate email address.

GumSlone

Can you explain how it works ??

For Latest Technology Tips & Tricks Click Here

Ponick Developer · 216 posts #7

last year i got some problem with lava native spam detecting function .if user input text like "some text ok.in our home or some text .come at 12pm" the function detect ".in" and ".com" as a domain and return false !

/* I don't know everything hehe */

Find me on facebook

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close