/**
* PHP从数据库查询email是否已经存在
*
* @param
* @author 网: jb51.cc
**/
// Use this
$email_is_valid = valid_email($email,$db);
// Function
function valid_email ($email,$db) {
$r_email = $db->prepare('SELECT COUNT(id) FROM inscriptions WHERE email = ?');
$r_email->execute(array($email));
$r_email_count = $r_email->fetchAll();
if ($r_email_count[0][0] == 0):
if (!filter_var($email,FILTER_VALIDATE_EMAIL)):
return true;
else:
return false;
endif;
else:
return true;
endif;
}
/*** 来自编程之家 jb51.cc(jb51.cc) ***/