• <bdo id='Rq48Y'></bdo><ul id='Rq48Y'></ul>

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

      <tfoot id='Rq48Y'></tfoot>

      <i id='Rq48Y'><tr id='Rq48Y'><dt id='Rq48Y'><q id='Rq48Y'><span id='Rq48Y'><b id='Rq48Y'><form id='Rq48Y'><ins id='Rq48Y'></ins><ul id='Rq48Y'></ul><sub id='Rq48Y'></sub></form><legend id='Rq48Y'></legend><bdo id='Rq48Y'><pre id='Rq48Y'><center id='Rq48Y'></center></pre></bdo></b><th id='Rq48Y'></th></span></q></dt></tr></i><div id='Rq48Y'><tfoot id='Rq48Y'></tfoot><dl id='Rq48Y'><fieldset id='Rq48Y'></fieldset></dl></div>
    1. <legend id='Rq48Y'><style id='Rq48Y'><dir id='Rq48Y'><q id='Rq48Y'></q></dir></style></legend>
    2. mysqli_real_escape_string 安全吗?

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

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

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

              1. 本文介绍了mysqli_real_escape_string 安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我是 PHP 新手,我意识到我的数据库连接,使用 php 表单(带有用户和传递文本输入)是完全不安全的:

                I´m new in PHP and I´ve realised that my database connection, using a php form (with user and pass text inputs) was totally unsafe:

                这是有效的,但不安全:

                This was working, but was unsafe:

                <?php
                $link=mysqli_connect('localhost','xx','xx','xx');
                $sql='  SELECT * FROM usuarios 
                        WHERE username="'.$_POST['usuario'].'" 
                        AND pass="'.$_POST['usuario'].'"
                     ';
                $rs=mysqli_query($link,$sql);
                mysqli_close($link);
                ?>
                

                所以,我已经阅读了 mysqli_real_escape_string,并决定尝试一下:

                So, I´ve read about mysqli_real_escape_string, and decided to try it out:

                <?php    
                $link=mysqli_connect('localhost','xx','xx','xx');
                $usuario=mysqli_real_escape_string($link, $_POST["usuario"]);
                $clave=mysqli_real_escape_string($link, $_POST["clave"]);
                $sql='  SELECT * FROM usuarios 
                        WHERE username="'.$usuario.'" 
                        AND pass="'.$clave.'"
                     ';
                $rs=mysqli_query($link,$sql);
                mysqli_close($link);
                ?>
                

                这是正确的吗?这是如何使用 mysqli_real_escape_string 的好例子吗?

                Is this correct? Is this a good example of how to use mysqli_real_escape_string?

                推荐答案

                这是正确的吗?

                是的.

                这是如何使用 mysqli_real_escape_string 的好例子吗?

                Is this a good example of how to use mysqli_real_escape_string?

                如果曾经使用过,这个函数必须被封装到一些内部处理中,并且永远不必从应用程序代码中直接调用.必须使用占位符来表示查询中的数据:

                $sql='SELECT * FROM usuarios WHERE username=? AND pass=?';
                

                然后,在处理占位符标记时,此功能可以被应用(如果适用)但不是单独应用,而是沿着所有格式规则应用.

                And then, upon processing placeholder marks, this function may be applied (if applicable) but not by itself but along ALL the formatting rules.

                这篇关于mysqli_real_escape_string 安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:mysqli_error() 期望参数 1 为 mysqli,null 是什么意思 下一篇:如何将任意数量的值绑定到 mysqli 中的准备好的语

                相关文章

                最新文章

              2. <small id='KK1Wf'></small><noframes id='KK1Wf'>

                <tfoot id='KK1Wf'></tfoot>
                  <bdo id='KK1Wf'></bdo><ul id='KK1Wf'></ul>

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