• <bdo id='7keup'></bdo><ul id='7keup'></ul>

    <small id='7keup'></small><noframes id='7keup'>

    1. <legend id='7keup'><style id='7keup'><dir id='7keup'><q id='7keup'></q></dir></style></legend>

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

      1. 如何使用 PHP 检查用户是否已存在于 MySQL 中

        时间:2023-07-30
        <i id='CAI8E'><tr id='CAI8E'><dt id='CAI8E'><q id='CAI8E'><span id='CAI8E'><b id='CAI8E'><form id='CAI8E'><ins id='CAI8E'></ins><ul id='CAI8E'></ul><sub id='CAI8E'></sub></form><legend id='CAI8E'></legend><bdo id='CAI8E'><pre id='CAI8E'><center id='CAI8E'></center></pre></bdo></b><th id='CAI8E'></th></span></q></dt></tr></i><div id='CAI8E'><tfoot id='CAI8E'></tfoot><dl id='CAI8E'><fieldset id='CAI8E'></fieldset></dl></div>

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

          1. <legend id='CAI8E'><style id='CAI8E'><dir id='CAI8E'><q id='CAI8E'></q></dir></style></legend>
                <bdo id='CAI8E'></bdo><ul id='CAI8E'></ul>
                  <tbody id='CAI8E'></tbody>
                • <tfoot id='CAI8E'></tfoot>
                  本文介绍了如何使用 PHP 检查用户是否已存在于 MySQL 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用以下对我不起作用的代码.

                  $con=mysqli_connect("localhost","root","","my_db");$check="SELECT COUNT(*) FROM people WHERE Email = '$_POST[eMailTxt]'";如果 (mysqli_query($con,$check)>=1){echo "用户已经存在<br/>";}别的{$newUser="INSERT INTO people(Email,FirstName,LastName,PassWord) values('$_POST[eMailTxt]','$_POST[NameTxt]','$_POST[LnameTxt]','$_POST[passWordTxt]')";如果 (mysqli_query($con,$newUser)){echo "您现在已注册<br/>";}别的{echo "在数据库中添加用户时出错<br/>";}}

                  <块引用>

                  mysqli_result 类的对象无法转换为 int inC:xampphtdocsExpwelcome.php

                  解决方案

                  这段代码很适合你...

                  $con=mysqli_connect("localhost","root","","my_db");$check="SELECT * FROM people WHERE Email = '$_POST[eMailTxt]'";$rs = mysqli_query($con,$check);$data = mysqli_fetch_array($rs, MYSQLI_NUM);如果($数据[0]> 1){echo "用户已经存在<br/>";}别的{$newUser="INSERT INTO people(Email,FirstName,LastName,PassWord) values('$_POST[eMailTxt]','$_POST[NameTxt]','$_POST[LnameTxt]','$_POST[passWordTxt]')";如果 (mysqli_query($con,$newUser)){echo "您现在已注册<br/>";}别的{echo "在数据库中添加用户时出错<br/>";}}

                  I am using following code which is not working for me.

                  $con=mysqli_connect("localhost","root","","my_db");
                  $check="SELECT COUNT(*) FROM persons WHERE Email = '$_POST[eMailTxt]'";
                  if (mysqli_query($con,$check)>=1)
                  {
                      echo "User Already in Exists<br/>";
                  }
                  else
                  {
                      $newUser="INSERT INTO persons(Email,FirstName,LastName,PassWord) values('$_POST[eMailTxt]','$_POST[NameTxt]','$_POST[LnameTxt]','$_POST[passWordTxt]')";
                      if (mysqli_query($con,$newUser))
                      {
                          echo "You are now registered<br/>";
                      }
                      else
                      {
                          echo "Error adding user in database<br/>";
                      }
                  }
                  

                  Object of class mysqli_result could not be converted to int in C:xampphtdocsExpwelcome.php

                  解决方案

                  this code works fine for you...

                  $con=mysqli_connect("localhost","root","","my_db");
                  $check="SELECT * FROM persons WHERE Email = '$_POST[eMailTxt]'";
                  $rs = mysqli_query($con,$check);
                  $data = mysqli_fetch_array($rs, MYSQLI_NUM);
                  if($data[0] > 1) {
                      echo "User Already in Exists<br/>";
                  }
                  
                  else
                  {
                      $newUser="INSERT INTO persons(Email,FirstName,LastName,PassWord) values('$_POST[eMailTxt]','$_POST[NameTxt]','$_POST[LnameTxt]','$_POST[passWordTxt]')";
                      if (mysqli_query($con,$newUser))
                      {
                          echo "You are now registered<br/>";
                      }
                      else
                      {
                          echo "Error adding user in database<br/>";
                      }
                  }
                  

                  这篇关于如何使用 PHP 检查用户是否已存在于 MySQL 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:与普通 mysqli 语句相比,使用准备好的语句的优势 下一篇:mysql &amp; 的区别mysqli

                  相关文章

                  最新文章

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

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

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

                    <legend id='J7ll3'><style id='J7ll3'><dir id='J7ll3'><q id='J7ll3'></q></dir></style></legend>

                    <tfoot id='J7ll3'></tfoot>