php防止sql注入之過濾分頁參數_PHP教程

來源:互聯網
上載者:User
我們會聽過這一種句話,在網路上不要相信任何輸入資訊,我們都必須進行參數過濾,下面我就來介紹過濾分頁參數吧,有需要的朋友可參考。

執行個體

代碼如下 複製代碼

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

其中:

代碼如下 複製代碼


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

這兩句判斷了參數是否為數字。防止非法字元輸入。

http://www.bkjia.com/PHPjc/629630.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/629630.htmlTechArticle我們會聽過這一種句話,在網路上不要相信任何輸入資訊,我們都必須進行參數過濾,下面我就來介紹過濾分頁參數吧,有需要的朋友可參...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.