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>

                            主站蜘蛛池模板: 深圳昂为官网-气体分析仪,沼气分析仪,动态配气仪,气体传感器厂家 | 电镀标牌_电铸标牌_金属标贴_不锈钢标牌厂家_深圳市宝利丰精密科技有限公司 | Maneurop/美优乐压缩机,活塞压缩机,型号规格,技术参数,尺寸图片,价格经销商 | 通辽信息港 - 免费发布房产、招聘、求职、二手、商铺等信息 www.tlxxg.net | 平面钻,法兰钻,三维钻-山东兴田阳光智能装备股份有限公司 | 缝纫客| 工业胀紧套_万向节联轴器_链条-规格齐全-型号选购-非标订做-厂家批发价格-上海乙谛精密机械有限公司 | 医学动画公司-制作3d医学动画视频-医疗医学演示动画制作-医学三维动画制作公司 | 艺术涂料_进口艺术涂料_艺术涂料加盟_艺术涂料十大品牌 -英国蒙太奇艺术涂料 | 桐城新闻网—桐城市融媒体中心主办| 钛板_钛管_钛棒_钛盘管-无锡市盛钛科技有限公司 | 防渗膜厂家|养殖防渗膜|水产养殖防渗膜-泰安佳路通工程材料有限公司 | OpenI 启智 新一代人工智能开源开放平台| 山楂片_雪花_迷你山楂片_山楂条饼厂家-青州市丰源食品厂 | 播音主持培训-中影人教育播音主持学苑「官网」-中国艺考界的贵族学校 | 标准光源箱|对色灯箱|色差仪|光泽度仪|涂层测厚仪_HRC大品牌生产厂家 | 河南mpp电力管_mpp电力管生产厂家_mpp电力电缆保护管价格 - 河南晨翀实业 | 广州展览设计公司_展台设计搭建_展位设计装修公司-众派展览装饰 广州展览制作工厂—[优简]直营展台制作工厂_展会搭建资质齐全 | 讲师宝经纪-专业培训机构师资供应商_培训机构找讲师、培训师、讲师经纪就上讲师宝经纪 | 金属管浮子流量计_金属转子流量计厂家-淮安润中仪表科技有限公司 | 欧必特空气能-商用空气能热水工程,空气能热水器,超低温空气源热泵生产厂家-湖南欧必特空气能公司 | 无缝方管|无缝矩形管|无缝方矩管|无锡方管厂家 | NM-02立式吸污机_ZHCS-02软轴刷_二合一吸刷软轴刷-厦门地坤科技有限公司 | 高精度-恒温冷水机-螺杆式冰水机-蒸发冷冷水机-北京蓝海神骏科技有限公司 | 冷油器,取样冷却器,热力除氧器-连云港振辉机械设备有限公司 | 工业设计,人工智能,体验式3D展示的智能技术交流服务平台-纳金网 J.S.Bach 圣巴赫_高端背景音乐系统_官网 | 高考志愿规划师_高考规划师_高考培训师_高报师_升学规划师_高考志愿规划师培训认证机构「向阳生涯」 | 水冷散热器_水冷电子散热器_大功率散热器_水冷板散热器厂家-河源市恒光辉散热器有限公司 | AGV无人叉车_激光叉车AGV_仓储AGV小车_AGV无人搬运车-南昌IKV机器人有限公司[官网] | 欧美日韩国产一区二区三区不_久久久久国产精品无码不卡_亚洲欧洲美洲无码精品AV_精品一区美女视频_日韩黄色性爱一级视频_日本五十路人妻斩_国产99视频免费精品是看4_亚洲中文字幕无码一二三四区_国产小萍萍挤奶喷奶水_亚洲另类精品无码在线一区 | 杭州中央空调维修_冷却塔/新风机柜/热水器/锅炉除垢清洗_除垢剂_风机盘管_冷凝器清洗-杭州亿诺能源有限公司 | 吸污车_吸粪车_抽粪车_电动三轮吸粪车_真空吸污车_高压清洗吸污车-远大汽车制造有限公司 | 齿辊分级破碎机,高低压压球机,立式双动力磨粉机-郑州长城冶金设备有限公司 | 江苏南京多语种翻译-专业翻译公司报价-正规商务翻译机构-南京华彦翻译服务有限公司 | AGV无人叉车_激光叉车AGV_仓储AGV小车_AGV无人搬运车-南昌IKV机器人有限公司[官网] | 混合反应量热仪-高温高压量热仪-微机差热分析仪DTA|凯璞百科 | 彩信群发_群发彩信软件_视频短信营销平台-达信通 | 高压微雾加湿器_工业加湿器_温室喷雾-昌润空气净化设备 | 天津试验仪器-电液伺服万能材料试验机,恒温恒湿标准养护箱,水泥恒应力压力试验机-天津鑫高伟业科技有限公司 | 专业生物有机肥造粒机,粉状有机肥生产线,槽式翻堆机厂家-郑州华之强重工科技有限公司 | 磷酸肌酸二钠盐,肌酐磷酰氯-沾化欣瑞康生物科技 |