Các chức năng vệ sinh đầu vào php tốt nhất là gì?

Why input đầu vào look lượt thích this.

Bạn đang xem: Các chức năng vệ sinh đầu vào php tốt nhất là gì?

demo.php

" style=" margin: 0px; width: 810px;height: 33px;line-height: 17px;line-height: 33px;^line-height: 33px;padding: 0px;margin-right: -1px;padding-left: 5px;-webkit-box-shadow: 0 2px 3px rgba(0,0,0,0.1);-moz-box-shadow: 0 2px 3px rgba(0,0,0,0.1); box-shadow: 0 2px 3px rgba(0,0,0,0.1); ">
php mysql-real-escape-string
Share
Follow
asked Aug 12 "16 at 6:39

*

peat wedtypeat wedty
5544 bronze badges
3
1
you really should not be using mysql API any more –web1_user557846 Aug 12 "16 at 6:40
Add a bình luận |

2 Answers 2


Active sầu Oldest Votes
1
mysql_real_escape_string escapes data so you can safely put it in an SQL query that you then sover to MySquốc lộ. (NB: mysql_real_escape_string is part of an obsolete API you should have sầu stopped using about half a decade ago.)

value="" That is not SQL. That is HTML, which you send to lớn a website browser.

HTML is a different language khổng lồ SQL. The escaping rules are different, not even subtly different, they are completely different.

You need to lớn use htmlspecialchars() lớn escape data so it is suitable for inserting into HTML.

Xem thêm: Hướng Dẫn Ghost Bằng Acronis True Image 2018, Hướng Dẫn Bung Ghost File Tib Chuẩn Uefi


Share
Follow
edited May 23 "17 at 12:01
*

Community♦
111 silver badge
answered Aug 12 "16 at 8:32
*

QuentinQuentin
800k104104 gold badges10791079 silver badges12051205 bronze badges
Add a bình luận |
-2
mysql API is deprecated, you really should not be using it try to lớn use mysqli

this is the syntaxmysqli_real_escape_string(connection,escapestring);it takes the connection object and the string you want to escape

a good example is this


Share
Follow
edited Aug 12 "16 at 8:29
answered Aug 12 "16 at 6:56

*

Babajide ApataBabajide Apata
52755 silver badges1717 bronze badges
1
Add a phản hồi |

Your Answer


Thanks for contributing an answer khổng lồ Staông xã Overflow!

Please be sure to answer the question. Provide details & nội dung your research!

But avoid

Asking for help, clarification, or responding to lớn other answers.Making statements based on opinion; bachồng them up with references or personal experience.

To learn more, see our tips on writing great answers.

Xem thêm: " Không Thể Truy Cập Trang Web Này ” Hiệu Quả, Không Có Trang Web Này


Draft saved
Draft discarded

Sign up or log in


Sign up using Google
Sign up using Facebook
Sign up using E-Mail and Password
Submit

Post as a guest


Name
Thư điện tử Required, but never shown


Post as a guest


Name
E-Mail

Required, but never shown


Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy


Not the answer you're looking for? Browse other questions tagged php mysql-real-escape-string or ask your own question.


The Overflow Blog
Featured on Meta
Linked
2580
Why shouldn't I use mysql_* functions in PHP?
Related
2091
When to lớn use self over $this?
92
Alternative khổng lồ mysql_real_escape_string without connecting to DB
4723
Reference — What does this symbol mean in PHP?
435
Why doesn't this code simply print letters A to Z?
2
mysql_real_escape_string not working
702
Squốc lộ injection that gets around mysql_real_escape_string()
983
PHP. array delete by value (not key)
0
I am looking for a way khổng lồ safely insert a string to a database?
1192
Reference - What does this error mean in PHP?
2580
Why shouldn't I use mysql_* functions in PHP?
Hot Network Questions more hot questions

Question feed
Subscribe lớn RSS
Question feed To subscribe khổng lồ this RSS feed, copy and paste this URL into your RSS reader.


*

lang-php
Stack Overflow
Products
Company
Stack Exchange Network
site thiết kế / hình ảnh sản phẩm © 2021 Stachồng Exchange Inc; web1_user contributions licensed under cc by-sa. rev2021.5.28.39383


Stack Overflow works best with JavaScript enabled
*

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and discthất bại information in accordance with our Cookie Policy.


Chuyên mục: Lập trình viên