| lamtin 发表于 2013-10-26 21:17  看这里
 https://github.com/EllisLab/CodeIgniter/blob/2.1.4/system/database/drivers/mysql/mysql_driver ...
谢谢版主,我这样写,就是下面的代码,应该不用担心安全问题吧?
 $this->db->insert('news', $data); 直接添加到数据库安全吗?入库前需要escape_str过滤吗?
 
 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
 class Login extends CI_Controller {
 
 function __construct()
 {
 parent::__construct();
 $this->load->database();
 $this->load->helper('url');
 
 $this->load->helper('form');
 }
 
 function index() {
 
 $data['title'] = '登录';
 $this->load->view('vip/login.php', $data);
 
 echo $name = $this->input->post('name',true);
 
 echo $passwd = $this->input->post('passwd',true);
 
 $this->add();
 }
 
 function add() {
 
 $data['name'] = $this->input->post('name',true);
 $data['passwd'] = $this->input->post('passwd',true);
 
 return $this->db->insert('news', $data);
 }
 }
 
 
 
 
 |