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

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

      1. <small id='u3jAb'></small><noframes id='u3jAb'>

      2. 如何检查邮箱是否已经注册?

        时间:2023-10-04
          • <bdo id='RrDJe'></bdo><ul id='RrDJe'></ul>
            <i id='RrDJe'><tr id='RrDJe'><dt id='RrDJe'><q id='RrDJe'><span id='RrDJe'><b id='RrDJe'><form id='RrDJe'><ins id='RrDJe'></ins><ul id='RrDJe'></ul><sub id='RrDJe'></sub></form><legend id='RrDJe'></legend><bdo id='RrDJe'><pre id='RrDJe'><center id='RrDJe'></center></pre></bdo></b><th id='RrDJe'></th></span></q></dt></tr></i><div id='RrDJe'><tfoot id='RrDJe'></tfoot><dl id='RrDJe'><fieldset id='RrDJe'></fieldset></dl></div>
              <legend id='RrDJe'><style id='RrDJe'><dir id='RrDJe'><q id='RrDJe'></q></dir></style></legend>

                  <tfoot id='RrDJe'></tfoot>

                    <tbody id='RrDJe'></tbody>

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

                  本文介绍了如何检查邮箱是否已经注册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试检查是否已经使用 PDO 注册了电子邮件,但到目前为止我还没有找到一个好的方法.这就是我迄今为止所拥有的.如果有帮助,连接变量是$con".另外,我需要在同一个文档中使用连接变量还是在包含的文档中工作?

                  I am trying to check to see if an email is already registered using PDO, but I have not found a good way to do this so far. This is what I have so far. And the connection variable is "$con" if that helps. Also, do I need the connection variable in the same document or will it being in a document that is included work?

                  <link rel="stylesheet" type="text/css" href="csserrors.css">
                  <?php
                  require 'header.php';
                  if (!$_POST['submit']) {
                  ?>
                  <html>
                  <a href="register.html">Regsiter here!</a>
                  <?php
                  } else {
                      require 'connect.php';
                      $firstname = ($_POST['firstname']);
                      $lastname = ($_POST['lastname']);
                      $email = ($_POST['email']);
                      $password = ($_POST['password']);
                      $passwordconf = ($_POST['passwordconf']);
                  
                      $errorfields = "<p class='errormsg'>Please fill out all the fields!</p>";
                      if (empty($firstname) || empty($lastname) || empty($email) || empty($password) || empty($passwordconf)) {
                          echo "$errorfields";
                      }
                      $erroremail = "<p class='errormsg'>Email is not in name@domain format!</p>";
                      $regex = "/^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+.[a-z]{2,}$/i";
                      if (!preg_match($regex, $email)) {
                          echo "$erroremail";
                      }
                      $errorpassword = "<p class='errormsg'>You passwords do not match!</p>";
                      if ($password != $passwordconf) {
                          echo "$errorpassword";
                      }
                  
                      //this is where email is checked
                  }
                  ?>
                  

                  推荐答案

                  试试这个,用你的连接凭据填写 DB_NAME、DB_USER_NAME 和 DB_USER_PASS 或者使用 $con 变量,如果一切都正确设置为 PDO 对象:

                  Try this, fill in DB_NAME, DB_USER_NAME, and DB_USER_PASS with your connection credentials or use the $con variable if everything is set up correctly as a PDO object with it:

                  $con = new PDO( 'mysql:host=localhost;dbname=DB_NAME;charset=UTF-8', 'DB_USER_NAME', 'DB_USER_PASS' );
                  
                  $query = $con->prepare( "SELECT `email` FROM `tbl_name` WHERE `email` = ?" );
                  $query->bindValue( 1, $email );
                  $query->execute();
                  
                  if( $query->rowCount() > 0 ) { # If rows are found for query
                       echo "Email found!";
                  }
                  else {
                       echo "Email not found!";
                  }
                  

                  这篇关于如何检查邮箱是否已经注册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:带 PDO 的多个刀片 下一篇:致命错误:在非对象上调用成员函数 fetchALL() - 在

                  相关文章

                  最新文章

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

                  <tfoot id='XdWr3'></tfoot>

                    <legend id='XdWr3'><style id='XdWr3'><dir id='XdWr3'><q id='XdWr3'></q></dir></style></legend>
                  1. <small id='XdWr3'></small><noframes id='XdWr3'>

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