php从数据库查询email是否已经存在
// 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; }