English 中文(简体)
电子邮件地址的有效领域
原标题:Check valid domains in an eMail address
  • 时间:2011-11-21 11:22:22
  •  标签:
  • php

我有以下职能:检查电子邮件是否有效:

function validate_email ($getemail, $type)
{
    $email = $getemail;
    if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $chkdomain = explode("@", $email);
        $domain = $chkdomain[1];
        switch ($type) :
            case 1: //FOR USERS
                if ($domain == "oxfordmontessori.com" || $domain == "student.com" || $domain == "vendor.com")
                    return  Not Valid ;
                else
                    return TRUE;
        endswitch
        ;
    } else {
        return FALSE;
    }
}

I am calling function in this way.

var_dump($email);
$response = validate_email($email,  1 );
var_dump($response);
if ($response == FALSE) {
    $error = "Incorrect Email-Id";
} elseif ($response ==  Not Valid ) {
    $error = "Email domain is not valid for user.";
}
var_dump($response);

该法典有以下问题:

  1. 功能是,通过电子邮件确认,如>>>>>>>和

  2. 如果职能恢复,则“电子邮件域对用户不适用”

其中一个问题仍然是,他们正在回到西非经货联盟,给我留下错误的<代码>。 电子邮件域对用户无效。

问题回答

如果将这个领域定在<编码>oxfordmontessori.comstudent.comvendor.com,则将“Not Valid”退回到@a.com@b.com。 除非您的制度旨在阻止人们利用这些特定领域。

也许,你要么有外部变量来储存错误,要么是争论中的点,而不是从功能中恢复多种数据类型。 无论是真实的还是虚假的,都可能是愤怒的,而不是真实的、虚假的和扼杀的组合。 我认为,扼杀(在检查养牛业者时)每次都是真实的。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签