English 中文(简体)
在我数据库内外获取数据的适当途径是什么?
原标题:What is the proper way to secure data going in & out of my database?
  • 时间:2011-11-10 15:17:08
  •  标签:
  • php
  • mysql
最佳回答

你们回过头来。 简言之,$row is a row come out of the database. 页: 1 它阻止人们提交含有可执行的SQ代码的数据。

一旦数据在数据库中安全,请在out用户数据需要通过http://php.net/manual/en/Function.htmlspecialchars.php” rel=“nofollow”htmlspecialchars进行。 此前,它曾打过该网页,以防止注射文字。

基本上,在进入数据库的路上,just before /update le,你需要逃避可能的执行。 在通往浏览器的道路上,just,在座标离开了您的浏览器之前,你必须避免可能受到迫害的Javagust和/或可解释的超文本。 总结应当是你在寄出浏览器或数据库之前掌握数据的最后一件事。

问题回答

这绝不是完整的答案。

在撰写任何新法典之前,你必须停止并认真考虑你想要完成什么。

换言之,你通过管理<条码>-mysql_real_einski_string功能而获得的是什么?

总的来说,你逃避客户提供的数据。 这有助于防止 s。 此外,你还应进一步证实客户所寄出的东西是可以接受的(例如“圣检”)。 例如,如果你期待数字输入,则不接受插图和范围检查数值。 如果你期望像一个名字那样提供扼杀数据,则不接受超文本,但为了核实长度,再次进行范围检查是可以接受的。 这两种情况都发生在客户提交数据时,而不是在你书写数据时。

Going a little further, your cookies should be encrypted and marked with the httponly flag to tell the browser that it is not for use in client side script. Even with that, you shouldn t trust the data in the cookie at all; so go ahead and run your sanity checks and still escape those values in queries.

我高度建议你访问OWASP网站,并通过所有问题阅读,以便更好地了解袭击如何奏效以及如何防范攻击。 网站 在不真正了解正在发生什么的情况下,应用安全就太重要了。

BTW, kudos to 你了解这一情况,并试图保护你的网站。 太多的发展中国家甚至根本不考虑安全。

如果你利用指定经营实体的延伸来建立清洁要求,你可以设立这样的职能(保障说明和界定其类型):

一种实例,即文字是文字说明,数字是:

public function InsertThis($number, $text) {
    $pdo = $this->getPdo();
    $sth = $pdo->prepare("INSERT INTO my_table (number, text) VALUES (:number, :text");
    $sth->bindParam( number ,$number,PDO::PARAM_INT);
    $sth->bindParam( text ,$text);
    $sth->execute();
}

rel=“nofollow” http://php.net/manual/en/book.pdo.php

You only need to use mysql_real_escape_string() when inserting/updating a row where the values have come from untrusted sources.

这包括:

  • $_GET
  • $_POST
  • $_COOKIE
  • Anything that comes from the browser
  • Etc..

只有在把事情输入数据库时,而不是当你去做事情时,你才应当使用这一工具,因为事情本来应该安全。

使用PDO





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签