【问题标题】:Email service providers PHP filter电子邮件服务提供商 PHP 过滤器
【发布时间】:2017-08-17 19:42:39
【问题描述】:

例如,我想为“gmail-hotmail-yahoo”用户创建自定义路径

<input type="email" name="email"/>

现在我想要简单的 PHP 代码来过滤电子邮件服务提供商

如果我的电子邮件是 HelloWorld@gmail.com,请转到 /gmailuser 路径

例子

<?php
$email = $_POST['email'];

if ($email == 'gmail email' ) {
    header('Location: /gmailusers');

   } elseif ($email == 'hotmail email') {
    header('Location: /liveusers');
} else {
 header('Location: /unknownusers');

}
?>

【问题讨论】:

    标签: php email


    【解决方案1】:

    使用stripos 查找(不区分大小写)电子邮件是否包含重定向用户所需的关键字:

    <?php
    $email = $_POST['email'];
    
    if (stripos($email, '@gmail.com') !== false) {
        header('Location: /gmailusers');
    
       } elseif (stripos($email, '@hotmail.') !== false) {
        header('Location: /liveusers');
    } else {
     header('Location: /unknownusers');
    
    }
    ?>
    

    【讨论】:

    • 我想投票,但我没有 15 个声望,所以有人投票给他
    • @rekobeko 即使您还不能对答案投赞成票,但您已经可以接受了 :)
    猜你喜欢
    • 1970-01-01
    • 2018-03-09
    • 1970-01-01
    • 2016-05-11
    • 2015-11-02
    • 2014-10-23
    • 1970-01-01
    • 1970-01-01
    • 2021-10-16
    相关资源
    最近更新 更多