这些天我一直在冲浪,并了解SQL INJECTION ATTACK.我试图在我的本地机器上实现如何做到这一点,以便我可以在我的系统中防止它...
我写了这样的代码
PHP代码:
if(count($_POST) > 0){
$con = mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db('acelera',$con) or die(mysql_error()); //
echo $sql = 'SELECT * FROM acl_user WHERE user_email = "'.$_POST['email'].'" AND user_password = "'.$_POST['pass'].'"';
$res_src = mysql_query($sql);
while($row = mysql_fetch_array($res_src)){
echo "<pre>";print_r($row);echo "</pre>";
}
}
Run Code Online (Sandbox Code Playgroud)
HTML代码:
<html>
<head></head>
<body>
EMAIL : <input type="text" name="email" id="email" /><br />
PASWD : <input type="text" name="pass" id="pass" /><br />
<input type="submit" name="btn_submit" value="submit email pass" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
通过这段代码如果我给输入," OR ""="
那么sql注入应该完成.但它不能正常工作.在帖子数据中,如果我在密码字段中给出上面的输入,我有附加斜线.
任何人都可以告诉我实际上SQL INJECTION ATTACK是如何完成的?(代码会更加明显)
我是zend框架的新手.我已经编写了这段代码来在我的网站上设置cookie.
public function setCookie($data){
$email_cookie = new Zend_Http_Cookie('user_email_id', $data['user_email_id'], $_SERVER['HTTP_HOST'], '', FALSE);
$pass_cookie = new Zend_Http_Cookie('user_password', $data['user_password'], $_SERVER['HTTP_HOST'], '', FALSE);
$cookie_jar = new Zend_Http_CookieJar();
$cookie_jar->addCookie($email_cookie);
$cookie_jar->addCookie($pass_cookie);
}
Run Code Online (Sandbox Code Playgroud)
我甚至不知道写这个代码,我的cookie是否设置?现在如果我想要检索cookie,我该怎么办呢?
我想在我的PHP脚本中包含外部js文件.我正在关注zend framework.Right现在我在控制器的init函数中添加js文件,就像这样.
public function init() {
$this->doUserAuthorisation();
parent::init();
$this->view->headScript()->appendFile($this->view->baseUrl().'/js/front_cal/jquery-1.3.2.min.js');
$this->view->headLink()->setStylesheet($this->view->baseUrl().'/styles/front_cal/calendar.css');
}
Run Code Online (Sandbox Code Playgroud)
我面临的问题是,js文件不包含.这是包含js文件的正确方法吗?
我想将浮点后的8位浮点值转换为浮点后的2位数.
例如.$ a = 2.200000 ==> 2.20
我正在使用PHP的圆形功能.圆的问题是,如果我的数字是2.200000,它将转换为2.2中的数字.我希望输出为2.20
任何人都可以建议可行的方法吗?
实际代码
$price = sprintf ("%.2f", round(($opt->price_value + ($opt->price_value * $this->row->prices[0]->taxes[0]->tax_rate)), 2));
Run Code Online (Sandbox Code Playgroud)
如果我的浮点数是2.2000000,我想要输出.那它应该还给我2.20.但是现在它又回到了2.2
我听说sprintf()
可以防止SQL注入.这是真的吗?如果是这样,怎么样?
为什么人们建议写这样的查询:
$sql = sprintf('SELECT * FROM TABLE WHERE COL1 = %s AND COL2 = %s',$col1,$col2);
Run Code Online (Sandbox Code Playgroud) 我想在视频ID已知时获取YouTube视频标题,仅使用JavaScript.可能吗?
有没有办法删除safari地址栏iOS 9.0.2
?
我已经尝试过以下方法隐藏地址栏但没有成功.
1.添加metatag.
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
Run Code Online (Sandbox Code Playgroud)
2.添加了JS代码.
window.addEventListener("load",function() {
// Set a timeout...
setTimeout(function(){
// Hide the address bar!
window.scrollTo(0, 1);
}, 0);
});
Run Code Online (Sandbox Code Playgroud)
但没有成功.谁能帮我这个?
我想获得特定表的最后插入ID.谁能告诉我怎么能得到那个?我们mysql_insert_id()
在mysql中.我们在sql server 2008中有类似的功能吗?
Yii提供列出的排序功能.如何禁用排序,以便在单击列标题时不会对我的记录进行排序?
在laravel 5.2中,我可以使用下面的代码上传文件,但找不到在数据库中存储上传文件名的方法.
$destinationPath = "test/";
$file = $request->file('profile_pic');
if($file->isValid()){
$file->move($destinationPath, $file->getClientOriginalName());
$user = User::findOrFail(Auth::user()->id);
$input = $request->all();
$input['profile_pic']->pathname = $destinationPath.$file->getClientOriginalName();
$user->update($request->all());
}
Run Code Online (Sandbox Code Playgroud)
有谁知道如何在db中存储文件名?
php ×9
javascript ×3
mysql ×2
cookies ×1
ios9 ×1
iphone ×1
jquery ×1
laravel ×1
laravel-5.1 ×1
laravel-5.2 ×1
sql ×1
yii ×1
yii-events ×1
youtube ×1