sql注入及防止SQL注入
来源:互联网 发布:淘宝客不战 编辑:程序博客网 时间:2024/06/15 16:42
<?php
header('content-type:text/html;charset=utf-8');
$dsn = "mysql:host=127.0.0.1;dbname=username";
$db = new PDO($dsn,'root','');
$username=shiyan;
$pwd=000;
//未设置预处理之前
$sel="select * from user where username='$username' and pwd='$pwd'";
$count=$db->query($sel);
$arrs = $count->fetchAll();
print_r($arrs);
//进行预处理之后
$sql="select * from user where username = ? and pwd = ?";
$stmt = $db->prepare($sql);
$exeres = $stmt->execute(array($username, $pwd));
if ($exeres) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
print_r($row);
}
}
?>
header('content-type:text/html;charset=utf-8');
$dsn = "mysql:host=127.0.0.1;dbname=username";
$db = new PDO($dsn,'root','');
$username=shiyan;
$pwd=000;
//未设置预处理之前
$sel="select * from user where username='$username' and pwd='$pwd'";
$count=$db->query($sel);
$arrs = $count->fetchAll();
print_r($arrs);
//进行预处理之后
$sql="select * from user where username = ? and pwd = ?";
$stmt = $db->prepare($sql);
$exeres = $stmt->execute(array($username, $pwd));
if ($exeres) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
print_r($row);
}
}
?>
0 0
- sql注入及防止SQL注入
- sql注入及防止SQL注入
- 防止sql注入
- asp 防止SQL注入
- sql注入防止办法
- sql注入防止办法
- 怎么防止[SQL注入
- 如何防止SQL注入
- 防止sql注入
- SQL注入防止攻击
- 防止sql注入攻击
- 防止SQL注入
- 如何防止SQL注入
- 防止SQL注入
- 防止SQL注入攻击
- 防止sql注入
- 防止SQL注入攻击
- 网站防止SQL注入
- Golang 命令行自动设置网卡名称为LAN or WAN
- 【学习笔记-php】php中__get方法的使用
- Mac下获取Android Studio的SHA1,MD5,SHA256值的方法
- Layer3 BGP-9 BGP特性
- 安裝 FOEX Developer Addon (FDA)
- sql注入及防止SQL注入
- LeetCode24 Swap Nodes in Pairs 25. Reverse Nodes in k-Group详解
- ubuntu开启sshd服务(转载)
- pppcloud云主机下linux环境变量设置错误后,如何恢复解决方案
- javascript sort函数探究
- Key escrow (escrowed keys)
- UGUI控件可拖拽移动类组件
- php+jQuery全选 反选
- ssh: connect to host localhost port 22: Connection refused