PHP prevents SQL injection by filtering paging parameters_PHP tutorial

WBOY
Release: 2016-07-13 17:11:00
Original
1078 people have browsed it

We have heard this saying, don’t trust any input information on the Internet, we all must filter parameters. Now I will introduce filtering paging parameters, friends in need can refer to it.

Example

The code is as follows
 代码如下 复制代码

$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.'页-留言本-大冶实验高中首届宏志班网站';
}
else{
    $data ['title'] = '留言本-大冶实验高中首届宏志班网站';
}
 
$data ['liuyan'] = $this->ly->getLy ( $pernum, $currentnum );

Copy code

 代码如下 复制代码

 
$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;

$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'] = 'First page';
$config ['last_link'] = 'Last page';
$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'] = 'Page'.$current_page.'-Guestbook-Website of the First Hongzhi Class of Daye Experimental High School';
}
else{
$data ['title'] = 'Guestbook-Website of the First Hongzhi Class of Daye Experimental High School';
}

$data ['liuyan'] = $this->ly->getLy ( $pernum, $currentnum );

Among them:
The code is as follows

Copy code

$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; These two sentences determine whether the parameter is a number. Prevent illegal character input. http://www.bkjia.com/PHPjc/629630.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629630.htmlTechArticleWe have heard this saying, don’t trust any input information on the Internet, we must all make parameters Filtering, let me introduce the filtering paging parameters. Friends in need can refer to...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!