Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,047 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,548 people online right now. Registration is fast and FREE... Join Now!




filter email id from mysql database

 
Reply to this topicStart new topic

filter email id from mysql database, how do i delete data frm mysql table using php email verification

joyalfernandes
23 Jul, 2008 - 11:43 PM
Post #1

New D.I.C Head
*

Joined: 26 Sep, 2006
Posts: 8


My Contributions
hello
i would like to know how to filter email id.


suppose i have 5 email id in mysql database table.

abc@yahoo.co
qbc@yahoo.com
abc@yah.co.in
sbc@yahoo.com
dbc@yahoo.co.usd


now i want to check if these are vaild and remove the invalid entries from mysql database, how do i do it??
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Filter Email Id From Mysql Database
23 Jul, 2008 - 11:55 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,435



Thanked: 64 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
If by valid you mean that it has a name, the at symbol, the domain, a dot, & finally the top level domain, then you'll need to use strpos.

This is from php.net
CODE

<?php
$mystring = 'abc';
$findme   = 'a';
$pos = strpos($mystring, $findme);

// Note our use of ===.  Simply == would not work as expected
// because the position of 'a' was the 0th (first) character.
if ($pos === false) {
    echo "The string '$findme' was not found in the string '$mystring'";
} else {
    echo "The string '$findme' was found in the string '$mystring'";
    echo " and exists at position $pos";
}

// We can search for the character, ignoring anything before the offset
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
?>



So you'll need to search the string, find the @ & find the dot. Then verify that there are strings on each side.
User is offlineProfile CardPM
+Quote Post

MitkOK
RE: Filter Email Id From Mysql Database
24 Jul, 2008 - 01:46 AM
Post #3

D.I.C Regular
Group Icon

Joined: 9 Aug, 2007
Posts: 314



Thanked: 12 times
Dream Kudos: 250
My Contributions
This is a function a use to check valid mail:
php
function valMail($email) { 

$regexp='/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/';

return preg_match($regexp, trim($email));

}

This will return 1 if the mail is valid and 0 if it's not.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 05:20PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month