pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    1. <tfoot id='SRpaX'></tfoot>

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

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

        <legend id='SRpaX'><style id='SRpaX'><dir id='SRpaX'><q id='SRpaX'></q></dir></style></legend>
        • <bdo id='SRpaX'></bdo><ul id='SRpaX'></ul>

        在 PHP 中,PDO 如何防止 SQL 注入?準(zhǔn)備好的語句如

        In PHP, how does PDO protect from SQL injections? How do prepared statements work?(在 PHP 中,PDO 如何防止 SQL 注入?準(zhǔn)備好的語句如何工作?)
        • <bdo id='ETdP8'></bdo><ul id='ETdP8'></ul>
        • <i id='ETdP8'><tr id='ETdP8'><dt id='ETdP8'><q id='ETdP8'><span id='ETdP8'><b id='ETdP8'><form id='ETdP8'><ins id='ETdP8'></ins><ul id='ETdP8'></ul><sub id='ETdP8'></sub></form><legend id='ETdP8'></legend><bdo id='ETdP8'><pre id='ETdP8'><center id='ETdP8'></center></pre></bdo></b><th id='ETdP8'></th></span></q></dt></tr></i><div class="l3y81sj" id='ETdP8'><tfoot id='ETdP8'></tfoot><dl id='ETdP8'><fieldset id='ETdP8'></fieldset></dl></div>

            <tbody id='ETdP8'></tbody>

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

        • <legend id='ETdP8'><style id='ETdP8'><dir id='ETdP8'><q id='ETdP8'></q></dir></style></legend>

              • <tfoot id='ETdP8'></tfoot>
                  本文介紹了在 PHP 中,PDO 如何防止 SQL 注入?準(zhǔn)備好的語句如何工作?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我了解保護(hù)數(shù)據(jù)庫免受 SQL 注入的正確方法是使用準(zhǔn)備好的語句.我想了解如何準(zhǔn)備好的語句保護(hù)我的數(shù)據(jù)庫.

                  I understand the right way to protect a db from SQL injection is by using prepared statements. I would like to understand how prepared statements protect my db.

                  對(duì)于初學(xué)者來說,準(zhǔn)備好的語句是否與參數(shù)化查詢"相同?

                  For starters, are prepared statements the same thing as "parameterised queries"?

                  舉個(gè)例子,我在我的代碼下面粘貼了在用戶表中插入新用戶的代碼.那安全嗎?PDO 如何工作以確保其安全?還需要做些什么來保護(hù)數(shù)據(jù)庫免受注入嗎?

                  As an example, I'm pasting below my code for the insertion of a new user in a user table. Is that secure? How does PDO work to make it secure? Does anything more needs to be done to secure the db from injection?

                  在Class_DB.php"中:

                  In 'Class_DB.php':

                  class DB {
                   private $dbHost;
                   private $dbName;
                   private $dbUser;
                   private $dbPassword;   
                   function __construct($dbHost, $dbName, $dbUser, $dbPassword) {
                    $this->dbHost=$dbHost;
                    $this->dbName=$dbName;
                    $this->dbUser=$dbUser;
                    $this->dbPassword=$dbPassword;
                   }
                   function createConnexion() {
                    return new PDO("mysql:host=$this->dbHost;dbName=$this->dbName", $this->dbUser, $this->dbPassword);
                   }
                  }
                  

                  在DAO_User.php"中:

                  In 'DAO_User.php':

                  require_once('Class_DB.php');
                  
                  class DAO_User {
                   private $dbInstance;
                   function __construct($dbInstance){
                    $this->dbInstance=$dbInstance;
                   }
                   function createUser($user){
                    $dbConnection=$this->dbInstance->createConnexion();
                    $query=$dbConnection->prepare("INSERT INTO users (userName, hashedPassword, userEmail) VALUES (?,?,?)");
                    $query->bindValue(1, $user->userName);
                    $query->bindValue(2, $user->hashedPassword);
                    $query->bindValue(3, $user->userEmail);
                    $query->execute();
                   }
                  }
                  

                  謝謝,

                  JDelage

                  推薦答案

                  好的,我在這個(gè)相關(guān)問題中找到了我的問題的答案:PDO 準(zhǔn)備好的語句是否足以防止 SQL 注入?

                  Ok, I found the answer to my question in this related question: Are PDO prepared statements sufficient to prevent SQL injection?

                  感謝 Haim 將這個(gè) Q 指向我.

                  Thanks to Haim for pointing this Q to me.

                  在非技術(shù)術(shù)語中,以下是準(zhǔn)備好的語句如何防止注入:

                  In non technical terms, here is how prepared statements protect from injection:

                  當(dāng)查詢發(fā)送到數(shù)據(jù)庫時(shí),它通常作為字符串發(fā)送.數(shù)據(jù)庫引擎將嘗試解析字符串并將數(shù)據(jù)與指令分開,依賴于引號(hào)和語法.因此,如果您發(fā)送SELECT * WHERE '用戶提交的數(shù)據(jù)' EQUALS '表行名稱',引擎將能夠解析指令.

                  When a query is sent to a data base, it's typically sent as a string. The db engine will try to parse the string and separate the data from the instructions, relying on quote marks and syntax. So if you send "SELECT * WHERE 'user submitted data' EQUALS 'table row name', the engine will be able to parse the instruction.

                  如果您允許用戶輸入將在用戶提交的數(shù)據(jù)"中發(fā)送的內(nèi)容,那么他??們可以在其中包含諸如..."或IF 1=1 ERASE DATABASE"之類的內(nèi)容.數(shù)據(jù)庫引擎將無法解析this 并將上述內(nèi)容作為指令而不是無意義的字符串.

                  If you allow a user to enter what will be sent inside 'user submitted data', then they can include in this something like '..."OR IF 1=1 ERASE DATABASE'. The db engine will have trouble parsing this and will take the above as an instruction rather than a meaningless string.

                  PDO 的工作方式是將指令 (prepare("INSERT INTO ...)) 和數(shù)據(jù)分開發(fā)送.數(shù)據(jù)是分開發(fā)送的,清楚地理解為數(shù)據(jù)和數(shù)據(jù)而已.db 引擎沒有甚至嘗試分析數(shù)據(jù)字符串的內(nèi)容,看看它是否包含指令,并且不考慮任何潛在的破壞性代碼片段.

                  The way PDO works is that it sends separately the instruction (prepare("INSERT INTO ...)) and the data. The data is sent separately, clearly understood as being data and data only. The db engine doesn't even try to analyze the content of the data string to see if it contains instructions, and any potentially damaging code snipet is not considered.

                  這篇關(guān)于在 PHP 中,PDO 如何防止 SQL 注入?準(zhǔn)備好的語句如何工作?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動(dòng)游標(biāo)不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術(shù)方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個(gè)值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動(dòng)程序)
                      <legend id='2tFV2'><style id='2tFV2'><dir id='2tFV2'><q id='2tFV2'></q></dir></style></legend>

                        <bdo id='2tFV2'></bdo><ul id='2tFV2'></ul>

                      • <small id='2tFV2'></small><noframes id='2tFV2'>

                      • <tfoot id='2tFV2'></tfoot>
                          <tbody id='2tFV2'></tbody>
                        1. <i id='2tFV2'><tr id='2tFV2'><dt id='2tFV2'><q id='2tFV2'><span id='2tFV2'><b id='2tFV2'><form id='2tFV2'><ins id='2tFV2'></ins><ul id='2tFV2'></ul><sub id='2tFV2'></sub></form><legend id='2tFV2'></legend><bdo id='2tFV2'><pre id='2tFV2'><center id='2tFV2'></center></pre></bdo></b><th id='2tFV2'></th></span></q></dt></tr></i><div class="xibn4rn" id='2tFV2'><tfoot id='2tFV2'></tfoot><dl id='2tFV2'><fieldset id='2tFV2'></fieldset></dl></div>

                            主站蜘蛛池模板: 活性氧化铝球|氧化铝干燥剂|分子筛干燥剂|氢氧化铝粉-淄博同心材料有限公司 | 网络推广公司_网络营销方案策划_企业网络推广外包平台-上海澜推网络 | 北京中创汇安科贸有限公司| 南京精锋制刀有限公司-纵剪机刀片_滚剪机刀片_合金刀片厂家 | 聚丙烯酰胺_阴离子_阳离子「用量少」巩义亿腾厂家直销,售后无忧 聚合甘油__盐城市飞龙油脂有限公司 | BAUER减速机|ROSSI-MERSEN熔断器-APTECH调压阀-上海爱泽工业设备有限公司 | 成都网站建设制作_高端网站设计公司「做网站送优化推广」 | 校园文化空间设计-数字化|中医文化空间设计-党建|法治廉政主题文化空间施工-山东锐尚文化传播公司 | BHK汞灯-百科|上海熙浩实业有限公司 | 淘剧影院_海量最新电视剧,免费高清电影随心观看 | 重庆磨床过滤机,重庆纸带过滤机,机床伸缩钣金,重庆机床钣金护罩-重庆达鸿兴精密机械制造有限公司 | IIS7站长之家-站长工具-爱网站请使用IIS7站长综合查询工具,中国站长【WWW.IIS7.COM】 | 超声波清洗机_超声波清洗机设备_超声波清洗机厂家_鼎泰恒胜 | 精密模具制造,注塑加工,吹塑和吹瓶加工,EPS泡沫包装生产 - 济南兴田塑胶有限公司 | 打孔器,打孔钳厂家【温州新星德牌五金工具】 | 收录网| 换网器_自动换网器_液压换网器--郑州海科熔体泵有限公司 | 北京森语科技有限公司-模型制作专家-展览展示-沙盘模型设计制作-多媒体模型软硬件开发-三维地理信息交互沙盘 | 广州监控安装公司_远程监控_安防弱电工程_无线wifi覆盖_泉威安防科技 | 联系我们老街华纳娱乐公司官网19989979996(客服) | 北钻固控设备|石油钻采设备-石油固控设备厂家 | 打包箱房_集成房屋-山东佳一集成房屋有限公司 | 打包箱房_集成房屋-山东佳一集成房屋有限公司 | 精密机械零件加工_CNC加工_精密加工_数控车床加工_精密机械加工_机械零部件加工厂 | 石家庄网站建设|石家庄网站制作|石家庄小程序开发|石家庄微信开发|网站建设公司|网站制作公司|微信小程序开发|手机APP开发|软件开发 | 碳化硅,氮化硅,冰晶石,绢云母,氟化铝,白刚玉,棕刚玉,石墨,铝粉,铁粉,金属硅粉,金属铝粉,氧化铝粉,硅微粉,蓝晶石,红柱石,莫来石,粉煤灰,三聚磷酸钠,六偏磷酸钠,硫酸镁-皓泉新材料 | 真空泵厂家_真空泵机组_水环泵_旋片泵_罗茨泵_耐腐蚀防爆_中德制泵 | 大型果蔬切片机-水果冬瓜削皮机-洗菜机切菜机-肇庆市凤翔餐饮设备有限公司 | 乳化沥青设备_改性沥青设备_沥青加温罐_德州市昊通路桥工程有限公司 | 家用净水器代理批发加盟_净水机招商代理_全屋净水器定制品牌_【劳伦斯官网】 | 金环宇|金环宇电线|金环宇电缆|金环宇电线电缆|深圳市金环宇电线电缆有限公司|金环宇电缆集团 | ★塑料拖链__工程拖链__电缆拖链__钢制拖链 - 【上海闵彬】 | 知名电动蝶阀,电动球阀,气动蝶阀,气动球阀生产厂家|价格透明-【固菲阀门官网】 | 电磁流量计_智能防腐防爆管道式计量表-金湖凯铭仪表有限公司 | 焊管生产线_焊管机组_轧辊模具_焊管设备_焊管设备厂家_石家庄翔昱机械 | 深圳离婚律师咨询「在线免费」华荣深圳婚姻律师事务所专办离婚纠纷案件 | 耐高温风管_耐高温软管_食品级软管_吸尘管_钢丝软管_卫生级软管_塑料波纹管-东莞市鑫翔宇软管有限公司 | 精密模具加工制造 - 富东懿| 企典软件一站式企业管理平台,可私有、本地化部署!在线CRM客户关系管理系统|移动办公OA管理系统|HR人事管理系统|人力 | 明渠式紫外线杀菌器-紫外线消毒器厂家-定州市优威环保 | 九爱图纸|机械CAD图纸下载交流中心 |