加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php防止sql注入之过滤分页参数实例

发布时间:2020-12-13 02:07:20 所属栏目:PHP教程 来源:网络整理
导读:《PHP实例:php防止sql注入之过滤分页参数实例》要点: 本文介绍了PHP实例:php防止sql注入之过滤分页参数实例,希望对您有用。如果有疑问,可以联系我们。 PHP编程 本篇章节讲解php防止sql注入中过滤分页参数的办法.供大家参考研究.具体分析如下:

《PHP实例:php防止sql注入之过滤分页参数实例》要点:
本文介绍了PHP实例:php防止sql注入之过滤分页参数实例,希望对您有用。如果有疑问,可以联系我们。

PHP编程本篇章节讲解php防止sql注入中过滤分页参数的办法.分享给大家供大家参考.具体分析如下:

PHP编程就网络平安而言,在网络上不要相信任何输入信息,对于任何输入信息我们都必须进行参数过滤.对此,我们先来看看下面的实例:

代码如下:
$this->load->library ( 'pagination' );
$config ['base_url'] = site_url () . '/guest/show';
$config ['total_rows'] = $c;
$config ['per_page'] = $pernum = 15;
$config ['uri_segment'] = 3;
$config ['use_page_numbers'] = TRUE;
$config ['first_link'] = '第一页';
$config ['last_link'] = '最后一页';
$config ['num_links'] = 5;
$this->pagination->initialize ( $config );
if (! $this->uri->segment ( 3 )) {
??? $currentnum = 0;
} else {
??? $currentnum = is_numeric($this->uri->segment ( 3 ))?(intval($this->uri->segment ( 3 ) - 1)) * $pernum:0;
}
?
$current_page=is_numeric($this->uri->segment ( 3 ))?intval($this->uri->segment ( 3 )):1;
if($current_page){
??? $data ['title'] = '第'.$current_page.'页-留言本-防SQL注入测试';
}
else{
??? $data ['title'] = '留言本-防SQL注入测试';
}
?
$data ['liuyan'] = $this->ly->getLy ( $pernum,$currentnum );

其中:
代码如下:
$current_page=is_numeric($this->uri->segment ( 3 ))?intval($this->uri->segment ( 3 )):1;
$currentnum = is_numeric($this->uri->segment ( 3 ))?(intval($this->uri->segment ( 3 ) - 1)) * $pernum;

这两句判断了参数是否为数字.防止非法字符输入.

PHP编程希望本文所述对大家的PHP程序设计有所赞助.

欢迎参与《PHP实例:php防止sql注入之过滤分页参数实例》讨论,分享您的想法,编程之家 52php.cn为您提供专业教程。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读