Home Backend Development PHP Tutorial 过滤get交付过来的变量htmlspecialchars就够了吧

过滤get交付过来的变量htmlspecialchars就够了吧

Jun 13, 2016 pm 01:16 PM
get htmlspecialchars magic quotes

过滤get提交过来的变量htmlspecialchars就够了吧?
比如要实现搜索用户名的功能,其实用户名是get过来的,用htmlspecialchars就够安全了吧?

PHP code

1

2

3

4

5

6

<!--

 

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

 

-->htmlspecialchars(trim($_GET['username']), ENT_QUOTES);

Copy after login


------解决方案--------------------
addslashes 处理(')、(")、(\)与 NULL
------解决方案--------------------
其实你是要防sql注入吧。对于
因此,最安全的还是通过 mysql_real_escape_string() 来转义防止攻击数据库, 可以下面这样写就安全了:

if (get_magic_quotes_gpc()) {
$username= stripslashes($_GET['username']);
}
else {
$username= $_GET['username'];
}

$username= mysql_real_escape_string($username);
...................................
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to automate tasks using PowerShell How to automate tasks using PowerShell Feb 20, 2024 pm 01:51 PM

If you are an IT administrator or technology expert, you must be aware of the importance of automation. Especially for Windows users, Microsoft PowerShell is one of the best automation tools. Microsoft offers a variety of tools for your automation needs, without the need to install third-party applications. This guide will detail how to leverage PowerShell to automate tasks. What is a PowerShell script? If you have experience using PowerShell, you may have used commands to configure your operating system. A script is a collection of these commands in a .ps1 file. .ps1 files contain scripts executed by PowerShell, such as basic Get-Help

Learn about Magic Eden's Diamond Rewards: Value Earned and How to Get It Learn about Magic Eden's Diamond Rewards: Value Earned and How to Get It Jan 26, 2024 pm 05:57 PM

Previously, MagicEden, a mainstream NFT market on the SOL chain, launched the Launchpad function. Prior to this, PANews has introduced the operating status of MagicEden and provided analysis on optimizing operating methods and investment methods for NFT trading platforms and users. Recently, MagicEden launched new activities in terms of operations and introduced diamond rewards to motivate users to use its products. In this article, PANews will explain in detail how to get MagicEden’s diamond reward and evaluate whether this reward is worth earning. Are MagicEden Diamond Rewards worth earning? According to the official blog, the MagicEden platform now offers users more long-term benefits through Diamond Rewards empowerment.

The largest foldable external screen! Honor Magic V Flip unveiled The largest foldable external screen! Honor Magic V Flip unveiled Jun 14, 2024 am 11:21 AM

According to news on June 13, today evening, Honor’s first small folding screen Honor Magic VFlip officially debuted. Different from other small foldables, Honor MagicVFlip brings the industry's largest vertically folding magic external screen. Its screen size is 4.0 inches, using a four-curved and equal-depth design. The screen-to-body ratio has reached an unprecedented 85%. From then on, the external screen is no longer The "secondary screen" is the main screen both inside and outside. At the same time, Honor MagicVFlip external screen also has screen quality comparable to flagships, industry-leading Honor eye protection screen, and full-scenario smart interaction. It is reported that the Honor MagicVFlip external screen is a global low-power LTPO external screen that achieves an industry-leading local peak brightness of 2500nit.

How does java initiate an http request and call the post and get interfaces? How does java initiate an http request and call the post and get interfaces? May 16, 2023 pm 07:53 PM

1. Java calls post interface 1. Use URLConnection or HttpURLConnection that comes with java. There is no need to download other jar packages. Call URLConnection. If the interface response code is modified by the server, the return message cannot be received. It can only be received when the response code is correct. to return publicstaticStringsendPost(Stringurl,Stringparam){OutputStreamWriterout=null;BufferedReaderin=null;StringBuilderresult=newSt

Can magic system be upgraded to Hongmeng? Can magic system be upgraded to Hongmeng? Dec 22, 2022 pm 02:29 PM

The magic system cannot be upgraded to Hongmeng, because the magic system belongs to Honor phones, and Honor has been separated from Huawei and is no longer a subsidiary of Huawei. Therefore, Honor phones released after November 17, 2020 do not support upgrading to Hongmeng. systematic.

Example of Curl Get command Example of Curl Get command Mar 20, 2024 pm 06:56 PM

In Linux, URL or Curl client is a popular command line utility that allows you to transfer data over the network using various protocols such as HTTPS, HTTP, FTP, etc. It allows you to send and receive data using its get, post and request methods. Among them, you need to use the &quot;get&quot; method frequently. Therefore, it becomes crucial to learn various methods and various options that you can use to increase your productivity. &quot;Performing a curl operation is as simple as entering a few simple commands. Although it seems simple, many users do not fully realize its potential. Therefore, this short guide provides some information on how to perform curl operations on Linux systems. Example using the &quot;curlget&quot; command.&quot; Curl

Zhao Ming warms up the Honor Magic V3: challenging the new height of foldable screen thinness and lightness Zhao Ming warms up the Honor Magic V3: challenging the new height of foldable screen thinness and lightness Jun 26, 2024 pm 03:51 PM

According to news on June 26, today, at the Shanghai MWC, Honor CEO Zhao Ming announced that Honor Magic V3 will be launched soon. This new product will challenge the new realm of foldable screens and thinness. Zhao Ming said that 12 months after the release of Honor MagicV2, no one has broken the record of thinness and lightness. Only Honor can surpass Honor. In July last year, the Honor MagicV2 had a folded thickness of only 9.9mm, an unfolded thickness of 4.7mm, and a weight of 231g. It broke the boundary between a candy bar machine and a folding screen, because when closed, it was almost as thick as a candy bar machine. and weight. It is reported that Honor MagicV2 uses the latest components such as screen, PU material, hinge, heat dissipation system, antenna, Type-C interface, fingerprint recognition, speakers, etc.

How to change Ubuntu's apt-get update source? How to change Ubuntu's apt-get update source? Jan 05, 2024 pm 03:40 PM

Manually modify Ubuntu's apt-get source 1. Use the ssh tool to connect to Ubuntu (I use xshell) 2. Type cd/etc/apt/3 on the command line and back up the source.list file in this directory (you must have sudo permissions) ), then there is a source.list.bak file. 4. Clear the source.list file content (note: it cannot be restored after clearing, so you need to perform the previous step to back up the file in advance). At this time, use sudo to prompt that the permissions are insufficient. Switch directly to the root user and execute this command. 5. Use vim to open source.list, press the i key to enter the editing mode, paste the source address to be modified, and then press

See all articles