<bdo id='tZq1P'></bdo><ul id='tZq1P'></ul>

        <i id='tZq1P'><tr id='tZq1P'><dt id='tZq1P'><q id='tZq1P'><span id='tZq1P'><b id='tZq1P'><form id='tZq1P'><ins id='tZq1P'></ins><ul id='tZq1P'></ul><sub id='tZq1P'></sub></form><legend id='tZq1P'></legend><bdo id='tZq1P'><pre id='tZq1P'><center id='tZq1P'></center></pre></bdo></b><th id='tZq1P'></th></span></q></dt></tr></i><div id='tZq1P'><tfoot id='tZq1P'></tfoot><dl id='tZq1P'><fieldset id='tZq1P'></fieldset></dl></div>
      1. <small id='tZq1P'></small><noframes id='tZq1P'>

      2. <tfoot id='tZq1P'></tfoot>

      3. <legend id='tZq1P'><style id='tZq1P'><dir id='tZq1P'><q id='tZq1P'></q></dir></style></legend>
      4. 正在注册的电子邮件的 PHP 检查域是“school.edu"地址

        PHP Check domain of email being registered is a #39;school.edu#39; address(正在注册的电子邮件的 PHP 检查域是“school.edu地址)

          <bdo id='o9hoA'></bdo><ul id='o9hoA'></ul>
        • <tfoot id='o9hoA'></tfoot>

              <tbody id='o9hoA'></tbody>
              <legend id='o9hoA'><style id='o9hoA'><dir id='o9hoA'><q id='o9hoA'></q></dir></style></legend>
              <i id='o9hoA'><tr id='o9hoA'><dt id='o9hoA'><q id='o9hoA'><span id='o9hoA'><b id='o9hoA'><form id='o9hoA'><ins id='o9hoA'></ins><ul id='o9hoA'></ul><sub id='o9hoA'></sub></form><legend id='o9hoA'></legend><bdo id='o9hoA'><pre id='o9hoA'><center id='o9hoA'></center></pre></bdo></b><th id='o9hoA'></th></span></q></dt></tr></i><div id='o9hoA'><tfoot id='o9hoA'></tfoot><dl id='o9hoA'><fieldset id='o9hoA'></fieldset></dl></div>

                  <small id='o9hoA'></small><noframes id='o9hoA'>

                1. 本文介绍了正在注册的电子邮件的 PHP 检查域是“school.edu"地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要为一个我正在从事的项目编写一个函数,目的是为了好玩,我们正在制作一个网站,仅供学校的学生、教职员工和校友访问.

                  I need to write a function for a project i'm working on for fun, where we're making a site only accessible to students, staff, and alumni at an institution.

                  假设学校网站是:school.edu.

                  Let's say the schools website is: school.edu.

                  我在编写用于检查提交的电子邮件地址是否具有school.edu"域的 php 过滤器时遇到问题

                  I'm having trouble writing a php filter that checks that the submitted email address has the domain of "school.edu"

                  我会举一个例子.Dude #1 的电子邮件是 user@mail.com,Dude #2 的电子邮件是 user@school.edu.我想确保 Dude 1 收到错误消息,并且 Dude #2 已成功注册.

                  I'll use an example. Dude #1 has an email of user@mail.com and Dude #2 has an email at user@school.edu. I want to make sure that Dude 1 gets an error message, and Dude #2 has a successful registration.

                  这就是我想要做的事情的要点.在不久的将来,该网站将允许另外两个地区学校注册:school2.edu 和 school3.edu.然后,我需要检查器根据域的小列表(可能是数组?)来检查电子邮件,以验证电子邮件是否属于列表中的域名.

                  That's the gist of what I'm trying to do. In the near future the site will allow registration by another two locale schools: school2.edu and school3.edu. I will then need the checker to check the email against a small list (maybe an array?) of domains to verify that the email is of a domain name on the list.

                  推荐答案

                  有几种方法可以实现这一点,这里是一种:

                  There's a few ways to accomplish this, here's one:

                  // Make sure we have input
                  // Remove extra white space if we do
                  $email = isset($_POST['email']) ? trim($_POST['email']) : null;
                  
                  // List of allowed domains
                  $allowed = [
                      'school.edu',
                      'school2.edu',
                      'school3.edu'
                  ];
                  
                  // Make sure the address is valid
                  if (filter_var($email, FILTER_VALIDATE_EMAIL))
                  {
                      // Separate string by @ characters (there should be only one)
                      $parts = explode('@', $email);
                  
                      // Remove and return the last part, which should be the domain
                      $domain = array_pop($parts);
                  
                      // Check if the domain is in our list
                      if ( ! in_array($domain, $allowed))
                      {
                          // Not allowed
                      }
                  }
                  

                  这篇关于正在注册的电子邮件的 PHP 检查域是“school.edu"地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                        <i id='rs9nN'><tr id='rs9nN'><dt id='rs9nN'><q id='rs9nN'><span id='rs9nN'><b id='rs9nN'><form id='rs9nN'><ins id='rs9nN'></ins><ul id='rs9nN'></ul><sub id='rs9nN'></sub></form><legend id='rs9nN'></legend><bdo id='rs9nN'><pre id='rs9nN'><center id='rs9nN'></center></pre></bdo></b><th id='rs9nN'></th></span></q></dt></tr></i><div id='rs9nN'><tfoot id='rs9nN'></tfoot><dl id='rs9nN'><fieldset id='rs9nN'></fieldset></dl></div>
                      1. <legend id='rs9nN'><style id='rs9nN'><dir id='rs9nN'><q id='rs9nN'></q></dir></style></legend>

                        <small id='rs9nN'></small><noframes id='rs9nN'>

                        <tfoot id='rs9nN'></tfoot>

                          • <bdo id='rs9nN'></bdo><ul id='rs9nN'></ul>
                              <tbody id='rs9nN'></tbody>